Init the encodedURL explicitly for CSSStyleSelectors. Construction time was too early to be passing in the
document m_url, since it doesn't get set during construction.
Fix for
3769643, crash on vancouverblast.org.
Reviewed by darin
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::CSSStyleSelector):
(khtml::CSSStyleSelector::init):
(khtml::CSSStyleSelector::setEncodedURL):
* khtml/css/cssstyleselector.h:
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::DocumentImpl):
(DocumentImpl::setURL):
(DocumentImpl::recalcStyleSelector):
* khtml/xml/dom_docimpl.h:
(DOM::DocumentImpl::URL):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7332
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-08-23 David Hyatt <hyatt@apple.com>
+
+ Fix for 3558334.
+
+ Init the encodedURL explicitly for CSSStyleSelectors. Construction time was too early to be passing in the
+ document m_url, since it doesn't get set during construction.
+
+ Fix for 3769643, crash on vancouverblast.org.
+
+ Reviewed by darin
+
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::CSSStyleSelector):
+ (khtml::CSSStyleSelector::init):
+ (khtml::CSSStyleSelector::setEncodedURL):
+ * khtml/css/cssstyleselector.h:
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::DocumentImpl):
+ (DocumentImpl::setURL):
+ (DocumentImpl::recalcStyleSelector):
+ * khtml/xml/dom_docimpl.h:
+ (DOM::DocumentImpl::URL):
+
2004-08-23 Kevin Decker <kdecker@apple.com>
Reviewed by Maciej.
static PseudoState pseudoState;
CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, StyleSheetListImpl *styleSheets,
- const KURL &url, bool _strictParsing )
+ bool _strictParsing )
{
init();
//kdDebug( 6080 ) << "number of style sheets in document " << authorStyleSheets.count() << endl;
//kdDebug( 6080 ) << "CSSStyleSelector: author style has " << authorStyle->count() << " elements"<< endl;
-
- KURL u = url;
-
- u.setQuery( QString::null );
- u.setRef( QString::null );
- encodedurl.file = u.url();
- int pos = encodedurl.file.findRev('/');
- encodedurl.path = encodedurl.file;
- if ( pos > 0 ) {
- encodedurl.path.truncate( pos );
- encodedurl.path += '/';
- }
- u.setPath( QString::null );
- encodedurl.host = u.url();
-
- //kdDebug() << "CSSStyleSelector::CSSStyleSelector encoded url " << encodedurl.path << endl;
}
CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
m_matchedRuleCount = m_matchedDeclCount = m_tmpRuleCount = 0;
}
+void CSSStyleSelector::setEncodedURL(const KURL& url)
+{
+ KURL u = url;
+
+ u.setQuery( QString::null );
+ u.setRef( QString::null );
+ encodedurl.file = u.url();
+ int pos = encodedurl.file.findRev('/');
+ encodedurl.path = encodedurl.file;
+ if ( pos > 0 ) {
+ encodedurl.path.truncate( pos );
+ encodedurl.path += '/';
+ }
+ u.setPath( QString::null );
+ encodedurl.host = u.url();
+
+ //kdDebug() << "CSSStyleSelector::CSSStyleSelector encoded url " << encodedurl.path << endl;
+}
+
CSSStyleSelector::~CSSStyleSelector()
{
delete m_authorStyle;
* creates a list of rules it needs to apply to objects
*/
CSSStyleSelector(DOM::DocumentImpl* doc, QString userStyleSheet,
- DOM::StyleSheetListImpl *styleSheets, const KURL &url,
+ DOM::StyleSheetListImpl *styleSheets,
bool _strictParsing);
/**
* same as above but for a single stylesheet.
bool canShareStyleWithElement(DOM::NodeImpl* e);
bool strictParsing;
- struct Encodedurl {
+
+ struct Encodedurl {
QString host; //also contains protocol
QString path;
QString file;
} encodedurl;
-
+ void setEncodedURL(const KURL& url);
+
// Given a CSS keyword in the range (xx-small to -khtml-xxx-large), this function will return
// the correct font size scaled relative to the user's default (medium).
float fontSizeForKeyword(int keyword, bool quirksMode) const;
void setMaximalOutlineSize(int o) { m_maximalOutlineSize = o; }
int maximalOutlineSize() const { return m_maximalOutlineSize; }
+
+ virtual QRect viewRect() const;
protected:
virtual void selectionStartEnd(int& spos, int& epos);
- virtual QRect viewRect() const;
-
KHTMLView *m_view;
RenderObject* m_selectionStart;
QRect RenderObject::viewRect() const
{
- return containingBlock()->viewRect();
+ return canvas()->viewRect();
}
bool RenderObject::absolutePosition(int &xPos, int &yPos, bool f)
m_usesDescendantRules = false;
m_usesSiblingRules = false;
- m_styleSelector = new CSSStyleSelector( this, m_usersheet, m_styleSheets, m_url,
- !inCompatMode() );
+ m_styleSelector = new CSSStyleSelector(this, m_usersheet, m_styleSheets, !inCompatMode());
m_windowEventListeners.setAutoDelete(true);
m_pendingStylesheets = 0;
m_ignorePendingStylesheets = false;
m_windowEventListeners.removeRef(it.current());
}
+void DocumentImpl::setURL(const QString& url)
+{
+ m_url = url;
+ if (m_styleSelector)
+ m_styleSelector->setEncodedURL(m_url);
+}
+
void DocumentImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet)
{
// kdDebug( 6030 ) << "HTMLDocument::setStyleSheet()" << endl;
QString usersheet = m_usersheet;
if ( m_view && m_view->mediaType() == "print" )
usersheet += m_printSheet;
- m_styleSelector = new CSSStyleSelector( this, usersheet, m_styleSheets, m_url,
- !inCompatMode() );
-
+ m_styleSelector = new CSSStyleSelector(this, usersheet, m_styleSheets, !inCompatMode());
+ m_styleSelector->setEncodedURL(m_url);
m_styleSelectorDirty = false;
}
void clear();
QString URL() const { return m_url; }
- void setURL(QString url) { m_url = url; }
+ void setURL(const QString& url);
QString baseURL() const { return m_baseURL.isEmpty() ? m_url : m_baseURL; }
void setBaseURL(const QString& baseURL) { m_baseURL = baseURL; }