Commit 6ad6e760 authored by ggaren's avatar ggaren

Reviewed by Darin Adler.

        Fixed a bug with Settings where a number of different objects held bare 
        Settings* data members, even though the Page owns the Settings object and 
        deletes it upon destruction.

        Added NULL checks since the Page can be deleted before the frame/document.

        * page/Settings.cpp: Removed reliance on setNeedsReapplyStylesForSettingsChange.

        * css/cssstyleselector.cpp: CSSStyleSelector was the worst offender. It 
        held a number of back pointers that were not guaranteed. I removed the 
        Settings*, Frame*, and FrameView* back pointers, but others could probably 
        go, too. I replaced them with a single Document* pointer, which is guaranteed
        because the Document owns the CSSStyleSelector.

        * page/Page.cpp: Removed setNeedsReapplyStylesForSettingsChange -- the 
        Settings object is now a proper subcontroller of Page, so it doesn't need
        to use a global table to find its page anymore. Also, this function
        confusingly implied that the Frames in a page can have heterogeneous settings,
        which is not true.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ea7fad3b
2007-05-24 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
Fixed a bug with Settings where a number of different objects held bare
Settings* data members, even though the Page owns the Settings object and
deletes it upon destruction.
Added NULL checks since the Page can be deleted before the frame/document.
* page/Settings.cpp: Removed reliance on setNeedsReapplyStylesForSettingsChange.
* css/cssstyleselector.cpp: CSSStyleSelector was the worst offender. It
held a number of back pointers that were not guaranteed. I removed the
Settings*, Frame*, and FrameView* back pointers, but others could probably
go, too. I replaced them with a single Document* pointer, which is guaranteed
because the Document owns the CSSStyleSelector.
* page/Page.cpp: Removed setNeedsReapplyStylesForSettingsChange -- the
Settings object is now a proper subcontroller of Page, so it doesn't need
to use a global table to find its page anymore. Also, this function
confusingly implied that the Frames in a page can have heterogeneous settings,
which is not true.
2007-05-25 David Hyatt <hyatt@apple.com>
Make sure -webkit-border-fit accounts for padding as well as border.
......@@ -351,7 +351,6 @@ __ZN7WebCore5Cache13getStatisticsEv
__ZN7WebCore5Cache14setMaximumSizeEj
__ZN7WebCore5Frame11scriptProxyEv
__ZN7WebCore5Frame11setIsActiveEb
__ZN7WebCore5Frame11setSettingsEPNS_8SettingsE
__ZN7WebCore5Frame11shouldCloseEv
__ZN7WebCore5Frame17bindingRootObjectEv
__ZN7WebCore5Frame17setWindowHasFocusEb
......
......@@ -58,7 +58,6 @@
#include "ProcessingInstruction.h"
#include "Range.h"
#include "RenderView.h"
#include "Settings.h"
#include "kjs_css.h"
#include "kjs_events.h"
#include "kjs_traversal.h"
......
......@@ -30,6 +30,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "Language.h"
#include "Page.h"
#include "PlugInInfoStore.h"
#include "Settings.h"
......@@ -514,7 +515,9 @@ JSValue *MimeType::getValueProperty(ExecState *exec, int token) const
case EnabledPlugin: {
ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
Frame *frame = interpreter->frame();
if (frame && frame->settings()->arePluginsEnabled())
ASSERT(frame);
Settings* settings = frame->settings();
if (settings && settings->arePluginsEnabled())
return new Plugin(exec, m_info->plugin);
else
return jsUndefined();
......@@ -541,7 +544,8 @@ JSValue *NavigatorFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const
return throwError(exec, TypeError);
Navigator *nav = static_cast<Navigator *>(thisObj);
// javaEnabled()
return jsBoolean(nav->frame()->settings()->isJavaEnabled());
Settings* settings = nav->frame() ? nav->frame()->settings() : 0;
return jsBoolean(settings && settings->isJavaEnabled());
}
} // namespace
......@@ -413,7 +413,7 @@ Window *Window::retrieveWindow(Frame *f)
{
JSObject *o = retrieve(f)->getObject();
ASSERT(o || !f->settings()->isJavaScriptEnabled());
ASSERT(o || !f->settings() || !f->settings()->isJavaScriptEnabled());
return static_cast<Window *>(o);
}
......@@ -530,9 +530,12 @@ UString Window::toString(ExecState *) const
static bool allowPopUp(ExecState *exec, Window *window)
{
return window->frame()
&& (window->frame()->settings()->JavaScriptCanOpenWindowsAutomatically()
|| static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture());
if (!window->frame())
return false;
if (static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture())
return true;
Settings* settings = window->frame()->settings();
return settings && settings->JavaScriptCanOpenWindowsAutomatically();
}
static HashMap<String, String> parseModalDialogFeatures(ExecState *exec, JSValue *featuresArg)
......
......@@ -222,10 +222,10 @@ static PseudoState pseudoState;
CSSStyleSelector::CSSStyleSelector(Document* doc, const String& userStyleSheet, StyleSheetList *styleSheets, bool _strictParsing)
{
init();
m_document = doc;
view = doc->view();
strictParsing = _strictParsing;
settings = doc->frame() ? doc->frame()->settings() : 0;
if (!defaultStyle)
loadDefaultStyle();
......@@ -237,6 +237,7 @@ CSSStyleSelector::CSSStyleSelector(Document* doc, const String& userStyleSheet,
// document doesn't have documentElement
// NOTE: this assumes that element that gets passed to styleForElement -call
// is always from the document that owns the style selector
FrameView* view = m_document->view();
if (view)
m_medium = new MediaQueryEvaluator(view->mediaType());
else
......@@ -300,7 +301,6 @@ CSSStyleSelector::CSSStyleSelector(CSSStyleSheet *sheet)
void CSSStyleSelector::init()
{
element = 0;
settings = 0;
m_matchedDecls.clear();
m_ruleList = 0;
m_collectRulesOnly = false;
......@@ -556,10 +556,7 @@ void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* defaultParen
parentStyle = defaultParent;
else
parentStyle = parentNode ? parentNode->renderStyle() : 0;
view = element->document()->view();
isXMLDoc = !element->document()->isHTMLDocument();
frame = element->document()->frame();
settings = frame ? frame->settings() : 0;
style = 0;
......@@ -773,7 +770,7 @@ void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule)
matchRules(defaultQuirksStyle, firstUARule, lastUARule);
// If we're in view source mode, then we match rules from the view source style sheet.
if (view && view->frame() && view->frame()->inViewSourceMode())
if (m_document->frame() && m_document->frame()->inViewSourceMode())
matchRules(defaultViewSourceStyle, firstUARule, lastUARule);
}
......@@ -2775,7 +2772,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
if (!primitiveValue->getIdent()) return;
EResize r;
EResize r = RESIZE_NONE;
switch(primitiveValue->getIdent()) {
case CSS_VAL_BOTH:
r = RESIZE_BOTH;
......@@ -2787,7 +2784,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
r = RESIZE_VERTICAL;
break;
case CSS_VAL_AUTO:
r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
if (Settings* settings = m_document->settings())
r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
break;
case CSS_VAL_NONE:
default:
......@@ -3145,8 +3143,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
double multiplier = 1.0;
// Scale for the font zoom factor only for types other than "em" and "ex", since those are
// already based on the font size.
if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && view && view->frame()) {
multiplier = view->frame()->zoomFactor() / 100.0;
if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && m_document->frame()) {
multiplier = m_document->frame()->zoomFactor() / 100.0;
}
lineHeight = Length(primitiveValue->computeLengthIntForLength(style, multiplier), Fixed);
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
......@@ -3323,9 +3321,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
if(!item->isPrimitiveValue()) continue;
CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue*>(item);
AtomicString face;
if(val->primitiveType() == CSSPrimitiveValue::CSS_STRING)
Settings* settings = m_document->settings();
if (val->primitiveType() == CSSPrimitiveValue::CSS_STRING)
face = static_cast<FontFamilyValue*>(val)->fontName();
else if (val->primitiveType() == CSSPrimitiveValue::CSS_IDENT) {
else if (val->primitiveType() == CSSPrimitiveValue::CSS_IDENT && settings) {
switch (val->getIdent()) {
case CSS_VAL__WEBKIT_BODY:
face = settings->standardFontFamily();
......@@ -4679,7 +4678,10 @@ void CSSStyleSelector::checkForGenericFamilyChange(RenderStyle* style, RenderSty
size = fontSizeForKeyword(CSS_VAL_XX_SMALL + childFont.keywordSize() - 1, style->htmlHacks(),
childFont.genericFamily() == FontDescription::MonospaceFamily);
} else {
float fixedScaleFactor = ((float)settings->defaultFixedFontSize()) / settings->defaultFontSize();
Settings* settings = m_document->settings();
float fixedScaleFactor = settings
? static_cast<float>(settings->defaultFixedFontSize()) / settings->defaultFontSize()
: 1;
size = (parentFont.genericFamily() == FontDescription::MonospaceFamily) ?
childFont.specifiedSize()/fixedScaleFactor :
childFont.specifiedSize()*fixedScaleFactor;
......@@ -4707,10 +4709,15 @@ float CSSStyleSelector::getComputedSizeFromSpecifiedSize(bool isAbsoluteSize, fl
// With the smart minimum, we never want to get smaller than the minimum font size to keep fonts readable.
// However we always allow the page to set an explicit pixel size that is smaller,
// since sites will mis-render otherwise (e.g., http://www.gamespot.com with a 9px minimum).
Settings* settings = m_document->settings();
if (!settings)
return 1.0f;
int minSize = settings->minimumFontSize();
int minLogicalSize = settings->minimumLogicalFontSize();
float zoomPercent = view ? view->frame()->zoomFactor()/100.0f : 1.0f;
float zoomPercent = m_document->frame() ? m_document->frame()->zoomFactor() / 100.0f : 1.0f;
float zoomedSize = specifiedSize * zoomPercent;
// Apply the hard minimum first. We only apply the hard minimum if after zooming we're still too small.
......@@ -4771,6 +4778,10 @@ static const float fontSizeFactors[totalKeywords] = { 0.60, 0.75, 0.89, 1.0, 1.2
float CSSStyleSelector::fontSizeForKeyword(int keyword, bool quirksMode, bool fixed) const
{
Settings* settings = m_document->settings();
if (!settings)
return 1.0f;
int mediumSize = fixed ? settings->defaultFixedFontSize() : settings->defaultFontSize();
if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax) {
// Look up the entry in the table.
......
......@@ -216,16 +216,14 @@ class StyledElement;
RenderStyle::PseudoId dynamicPseudo;
Document* m_document; // back pointer to owner document
RenderStyle *style;
RenderStyle *parentStyle;
Element *element;
StyledElement *styledElement;
Node *parentNode;
RenderStyle::PseudoId pseudoStyle;
FrameView *view;
Frame *frame;
CSSValue* m_lineHeightValue;
const Settings *settings;
bool fontDirty;
bool isXMLDoc;
......
......@@ -36,6 +36,7 @@
#include "Image.h"
#include "ImageDocument.h"
#include "MediaList.h"
#include "Page.h"
#include "PluginDocument.h"
#include "PlugInInfoStore.h"
#include "RegularExpression.h"
......@@ -370,8 +371,11 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
return new PluginDocument(this, frame);
#if ENABLE(SVG)
if (type == "image/svg+xml" && (!frame || !frame->settings()->usesDashboardBackwardCompatibilityMode()))
return new SVGDocument(this, frame);
if (type == "image/svg+xml") {
Settings* settings = frame ? frame->settings() : 0;
if (!settings || !settings->usesDashboardBackwardCompatibilityMode())
return new SVGDocument(this, frame);
}
#endif
if (isXMLMIMEType(type))
return new Document(this, frame);
......
......@@ -84,6 +84,7 @@
#include "RenderWidget.h"
#include "SegmentedString.h"
#include "SelectionController.h"
#include "Settings.h"
#include "StringHash.h"
#include "StyleSheetList.h"
#include "SystemTime.h"
......@@ -718,8 +719,8 @@ String Document::inputEncoding() const
String Document::defaultCharset() const
{
if (Frame* f = frame())
return f->settings()->defaultTextEncodingName();
if (Settings* settings = this->settings())
return settings->defaultTextEncodingName();
return String();
}
......@@ -902,8 +903,12 @@ Frame* Document::frame() const
Page* Document::page() const
{
Frame* frame = this->frame();
return frame ? frame->page() : 0;
return m_frame ? m_frame->page() : 0;
}
Settings* Document::settings() const
{
return m_frame ? m_frame->settings() : 0;
}
PassRefPtr<Range> Document::createRange()
......@@ -974,8 +979,7 @@ void Document::recalcStyle(StyleChange change)
FontDescription fontDescription;
fontDescription.setUsePrinterFont(printing());
if (Frame* f = frame()) {
const Settings *settings = f->settings();
if (Settings* settings = this->settings()) {
if (printing() && !settings->shouldPrintBackgrounds())
_style->setForceBackgroundsToWhite(true);
const AtomicString& stdfont = settings->standardFontFamily();
......
......@@ -80,6 +80,7 @@ namespace WebCore {
class Range;
class RegisteredEventListener;
class RenderArena;
class Settings;
class StyleSheet;
class StyleSheetList;
class Text;
......@@ -302,6 +303,7 @@ public:
FrameView* view() const; // can be NULL
Frame* frame() const; // can be NULL
Page* page() const; // can be NULL
Settings* settings() const; // can be NULL
PassRefPtr<Range> createRange();
......
......@@ -31,6 +31,7 @@
#include "Document.h"
#include "Editor.h"
#include "Frame.h"
#include "Page.h"
#include "PlatformString.h"
#include "SelectionController.h"
#include "Settings.h"
......@@ -169,7 +170,8 @@ bool enabledAnyEditableSelection(Frame* frame)
bool enabledPaste(Frame* frame)
{
return frame->settings()->isDOMPasteAllowed() && frame->editor()->canPaste();
Settings* settings = frame ? frame->settings() : 0;
return settings && settings->isDOMPasteAllowed() && frame->editor()->canPaste();
}
bool enabledAnyRangeSelection(Frame* frame)
......
......@@ -40,6 +40,7 @@
#include "HTMLNames.h"
#include "IndentOutdentCommand.h"
#include "InsertListCommand.h"
#include "Page.h"
#include "ReplaceSelectionCommand.h"
#include "SelectionController.h"
#include "Settings.h"
......@@ -125,7 +126,8 @@ bool JSEditor::queryCommandState(const String& command)
bool JSEditor::queryCommandSupported(const String& command)
{
if ((!m_document->frame() || !m_document->frame()->settings()->isDOMPasteAllowed()) && command.lower() == "paste")
Settings* settings = m_document->settings();
if ((!settings || !settings->isDOMPasteAllowed()) && command.lower() == "paste")
return false;
return commandImp(command) != 0;
}
......@@ -519,7 +521,8 @@ bool enabledCopy(Frame* frame)
bool enabledPaste(Frame* frame)
{
return frame->settings()->isDOMPasteAllowed() && frame->editor()->canPaste();
Settings* settings = frame ? frame->settings() : 0;
return settings && settings->isDOMPasteAllowed() && frame->editor()->canPaste();
}
bool enabledAnyRangeSelection(Frame* frame)
......
......@@ -507,7 +507,8 @@ void CanvasRenderingContext2D::stroke()
}
#endif
if (m_canvas && m_canvas->document()->frame() && m_canvas->document()->frame()->settings()->usesDashboardBackwardCompatibilityMode())
Settings* settings = m_canvas ? m_canvas->document()->settings() : 0;
if (settings && settings->usesDashboardBackwardCompatibilityMode())
state().m_path.clear();
}
......
......@@ -142,8 +142,8 @@ void HTMLAnchorElement::defaultEventHandler(Event* evt)
// If the link is editable, then we need to check the settings to see whether or not to follow the link
if (isContentEditable()) {
EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
if (document()->frame() && document()->frame()->settings())
editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior();
if (Settings* settings = document()->settings())
editableLinkBehavior = settings->editableLinkBehavior();
switch (editableLinkBehavior) {
// Always follow the link (Safari 2.0 behavior)
......@@ -241,8 +241,8 @@ void HTMLAnchorElement::setActive(bool down, bool pause)
{
if (isContentEditable()) {
EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
if (document()->frame() && document()->frame()->settings())
editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior();
if (Settings* settings = document()->settings())
editableLinkBehavior = settings->editableLinkBehavior();
switch(editableLinkBehavior) {
default:
......@@ -466,8 +466,8 @@ bool HTMLAnchorElement::isLiveLink() const
return true;
EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
if (document() && document()->frame() && document()->frame()->settings())
editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior();
if (Settings* settings = document()->settings())
editableLinkBehavior = settings->editableLinkBehavior();
switch(editableLinkBehavior) {
default:
......
......@@ -110,9 +110,9 @@ bool HTMLAppletElement::rendererIsNeeded(RenderStyle *style)
RenderObject *HTMLAppletElement::createRenderer(RenderArena *arena, RenderStyle *style)
{
Frame *frame = document()->frame();
Settings* settings = document()->settings();
if (frame && frame->settings()->isJavaEnabled()) {
if (settings && settings->isJavaEnabled()) {
HashMap<String, String> args;
args.set("code", getAttribute(codeAttr));
......@@ -143,18 +143,17 @@ RenderObject *HTMLAppletElement::createRenderer(RenderArena *arena, RenderStyle
#if USE(JAVASCRIPTCORE_BINDINGS)
KJS::Bindings::Instance *HTMLAppletElement::getInstance() const
{
Frame *frame = document()->frame();
if (!frame || !frame->settings()->isJavaEnabled())
Settings* settings = document()->settings();
if (!settings || !settings->isJavaEnabled())
return 0;
if (m_instance)
return m_instance.get();
RenderApplet *r = static_cast<RenderApplet*>(renderer());
if (r) {
if (RenderApplet* r = static_cast<RenderApplet*>(renderer())) {
r->createWidgetIfNecessary();
if (r->widget())
m_instance = frame->createScriptInstanceForWidget(r->widget());
if (r->widget() && document()->frame())
m_instance = document()->frame()->createScriptInstanceForWidget(r->widget());
}
return m_instance.get();
}
......
......@@ -86,8 +86,9 @@ HTMLCanvasElement::~HTMLCanvasElement()
}
HTMLTagStatus HTMLCanvasElement::endTagRequirement() const
{
if (document()->frame() && document()->frame()->settings()->usesDashboardBackwardCompatibilityMode())
{
Settings* settings = document()->settings();
if (settings && settings->usesDashboardBackwardCompatibilityMode())
return TagStatusForbidden;
return HTMLElement::endTagRequirement();
......@@ -95,7 +96,8 @@ HTMLTagStatus HTMLCanvasElement::endTagRequirement() const
int HTMLCanvasElement::tagPriority() const
{
if (document()->frame() && document()->frame()->settings()->usesDashboardBackwardCompatibilityMode())
Settings* settings = document()->settings();
if (settings && settings->usesDashboardBackwardCompatibilityMode())
return 0;
return HTMLElement::tagPriority();
......@@ -111,7 +113,8 @@ void HTMLCanvasElement::parseMappedAttribute(MappedAttribute* attr)
RenderObject* HTMLCanvasElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
if (document()->frame() && document()->frame()->settings()->isJavaScriptEnabled()) {
Settings* settings = document()->settings();
if (settings && settings->isJavaScriptEnabled()) {
m_rendererIsCanvas = true;
return new (arena) RenderHTMLCanvas(this);
}
......
......@@ -200,10 +200,9 @@ String HTMLFrameElementBase::location() const
void HTMLFrameElementBase::setLocation(const String& str)
{
if (m_URL == str)
if (Frame* frame = document()->frame())
if (frame->settings()->needsAcrobatFrameReloadingQuirk())
return;
Settings* settings = document()->settings();
if (settings && settings->needsAcrobatFrameReloadingQuirk() && m_URL == str)
return;
m_URL = AtomicString(str);
......
......@@ -750,8 +750,11 @@ bool HTMLParser::noframesCreateErrorCheck(Token* t, RefPtr<Node>& result)
bool HTMLParser::noscriptCreateErrorCheck(Token* t, RefPtr<Node>& result)
{
if (!m_isParsingFragment && document->frame() && document->frame()->settings()->isJavaScriptEnabled())
setSkipMode(noscriptTag);
if (!m_isParsingFragment) {
Settings* settings = document->settings();
if (settings && settings->isJavaScriptEnabled())
setSkipMode(noscriptTag);
}
return true;
}
......@@ -897,8 +900,13 @@ bool HTMLParser::isInline(Node* node) const
e->hasLocalName(abbrTag) || e->hasLocalName(acronymTag) || e->hasLocalName(subTag) ||
e->hasLocalName(supTag) || e->hasLocalName(spanTag) || e->hasLocalName(nobrTag) ||
e->hasLocalName(noframesTag) || e->hasLocalName(nolayerTag) ||
e->hasLocalName(noembedTag) || (e->hasLocalName(noscriptTag) && !m_isParsingFragment && document->frame() && document->frame()->settings()->isJavaScriptEnabled()))
e->hasLocalName(noembedTag))
return true;
if (e->hasLocalName(noscriptTag) && !m_isParsingFragment) {
Settings* settings = document->settings();
if (settings && settings->isJavaScriptEnabled())
return true;
}
}
return false;
......
......@@ -29,6 +29,7 @@
#include "Frame.h"
#include "FrameTree.h"
#include "HTMLNames.h"
#include "Page.h"
#include "RenderWidget.h"
#include "Settings.h"
#include "Widget.h"
......@@ -174,13 +175,22 @@ void HTMLPlugInElement::defaultEventHandler(Event* event)
NPObject* HTMLPlugInElement::createNPObject()
{
// This shouldn't ever happen, but might as well check anyway
if (!document()->frame())
Frame* frame = document()->frame();
if (!frame) {
// This shouldn't ever happen, but might as well check anyway.
ASSERT_NOT_REACHED();
return _NPN_CreateNoScriptObject();
}
Settings* settings = frame->settings();
if (!settings) {
// This shouldn't ever happen, but might as well check anyway.
ASSERT_NOT_REACHED();
return _NPN_CreateNoScriptObject();
}
// Can't create NPObjects when JavaScript is disabled
Frame* frame = document()->frame();
if (!frame->settings()->isJavaScriptEnabled())
if (!settings->isJavaScriptEnabled())
return _NPN_CreateNoScriptObject();
// Create a JSObject bound to this element
......
......@@ -41,7 +41,7 @@
#include "HTMLParser.h"
#include "HTMLScriptElement.h"
#include "HTMLViewSourceDocument.h"
#include "Page.h"
#include "Settings.h"
#include "SystemTime.h"
#include "csshelper.h"
#include "kjs_proxy.h"
......@@ -1190,13 +1190,16 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
Attribute* a = 0;
scriptSrc = String();
scriptSrcCharset = String();
if (currToken.attrs && !m_fragment && m_doc->frame() && m_doc->frame()->settings()->isJavaScriptEnabled()) {
if ((a = currToken.attrs->getAttributeItem(srcAttr)))
scriptSrc = m_doc->completeURL(parseURL(a->value()));
if ((a = currToken.attrs->getAttributeItem(charsetAttr)))
scriptSrcCharset = a->value().domString().stripWhiteSpace();
if (scriptSrcCharset.isEmpty())
scriptSrcCharset = m_doc->frame()->loader()->encoding();
if (currToken.attrs && !m_fragment) {
Settings* settings = m_doc->settings();
if (settings && settings->isJavaScriptEnabled()) {
if ((a = currToken.attrs->getAttributeItem(srcAttr)))
scriptSrc = m_doc->completeURL(parseURL(a->value()));
if ((a = currToken.attrs->getAttributeItem(charsetAttr)))
scriptSrcCharset = a->value().domString().stripWhiteSpace();
if (scriptSrcCharset.isEmpty())
scriptSrcCharset = m_doc->frame()->loader()->encoding();
}
}
}
......
......@@ -438,8 +438,13 @@ print <<END
${namespace}Element *${namespace}ElementFactory::create${namespace}Element(const QualifiedName& qName, Document* doc, bool createdByParser)
{
#if ENABLE(SVG)
if (!doc || (doc->page() && doc->page()->settings()->usesDashboardBackwardCompatibilityMode()))
return 0; // Do not allow elements to ever be made without having a doc or if we're in dashboard compatibility mode.
// Don't make elements without a document
if (!doc)
return 0;
Settings* settings = doc->settings();
if (settings && settings->usesDashboardBackwardCompatibilityMode())
return 0;
createFunctionMapIfNecessary();
ConstructorFunc func = gFunctionMap->get(qName.localName().impl());
......
......@@ -27,7 +27,6 @@
#include "CachedResource.h"
#include "CachePolicy.h"
#include "Settings.h"
#include "StringHash.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
......
......@@ -868,11 +868,11 @@ void FrameLoader::begin(const KURL& url)
updatePolicyBaseURL();
document->docLoader()->setAutoLoadImages(m_frame->settings()->loadsImagesAutomatically());
const KURL& userStyleSheet = m_frame->settings()->userStyleSheetLocation();
Settings* settings = document->settings();
document->docLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically());
KURL userStyleSheet = settings ? settings->userStyleSheetLocation() : KURL();
if (!userStyleSheet.isEmpty())
m_frame->setUserStyleSheetLocation(KURL(userStyleSheet));
m_frame->setUserStyleSheetLocation(userStyleSheet);
restoreDocumentState();
......@@ -910,7 +910,8 @@ void FrameLoader::write(const char* str, int len, bool flush)
}
if (!m_decoder) {
m_decoder = new TextResourceDecoder(m_responseMIMEType, m_frame->settings()->defaultTextEncodingName());
Settings* settings = m_frame->settings();
m_decoder = new TextResourceDecoder(m_responseMIMEType, settings ? settings->defaultTextEncodingName() : String());
if (!m_encoding.isNull())
m_decoder->setEncoding(m_encoding,
m_encodingWasChosenByUser ? TextResourceDecoder::UserChosenEncoding : TextResourceDecoder::EncodingFromHTTPHeader);
......@@ -1377,7 +1378,8 @@ String FrameLoader::encoding() const
return m_encoding;
if (m_decoder && m_decoder->encoding().isValid())
return m_decoder->encoding().name();
return m_frame->settings()->defaultTextEncodingName();
Settings* settings = m_frame->settings();
return settings ? settings->defaultTextEncodingName() : String();
}