[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: Re: Please Review: CSS Media
From: Martijn Klingens <mklingens () ism ! nl>
Date: 2001-10-26 8:39:52
[Download RAW message or body]
On Friday 26 October 2001 09:03, Simon Hausmann wrote:
> On Thu, Oct 25, 2001 at 02:42:36PM +0200, Martijn Klingens wrote:
> > Ok, this is hopefully the definitive patch to add CSS2 media support to
>
> A micro nitpick from me ;-)
>
> QString KHTMLView::mediaType() and bool MediaListImpl::contains(
> const QString & ) should probably be const :-)
Yeah... Somehow I automatically add const in front of function arguments, but
I always forget to make the whole method const when applicable, not only in
this case :(
Is this better? :-)
Martijn
["media2.diff" (text/x-diff)]
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.419
diff -u -3 -p -r1.419 khtmlview.cpp
--- khtmlview.cpp 2001/10/22 20:13:33 1.419
+++ khtmlview.cpp 2001/10/26 07:49:03
@@ -174,6 +174,8 @@ void KHTMLToolTip::maybeTip(const QPoint
KHTMLView::KHTMLView( KHTMLPart *part, QWidget *parent, const char *name)
: QScrollView( parent, name, WResizeNoErase | WRepaintNoErase )
{
+ m_medium = "screen";
+
m_part = part;
d = new KHTMLViewPrivate;
QScrollView::setVScrollBarMode(d->vmode);
@@ -867,6 +869,16 @@ bool KHTMLView::gotoLinkInternal(bool fo
return true;
}
+void KHTMLView::setMediaType( const QString &medium )
+{
+ m_medium = medium;
+}
+
+QString KHTMLView::mediaType() const
+{
+ return m_medium;
+}
+
void KHTMLView::print()
{
if(!m_part->xmlDocImpl()) return;
@@ -885,9 +897,11 @@ void KHTMLView::print()
QPainter *p = new QPainter;
p->begin( printer );
- khtml::setPrintPainter( p );
+ khtml::setPrintPainter( p );
m_part->xmlDocImpl()->setPaintDevice( printer );
+ QString oldMediaType = mediaType();
+ setMediaType( "print" );
QPaintDeviceMetrics metrics( printer );
@@ -954,7 +968,8 @@ void KHTMLView::print()
// and now reset the layout to the usual one...
root->setPrintingMode(false);
- khtml::setPrintPainter( 0 );
+ khtml::setPrintPainter( 0 );
+ setMediaType( oldMediaType );
m_part->xmlDocImpl()->setPaintDevice( this );
m_part->setFontSizes(oldSizes);
m_part->xmlDocImpl()->applyChanges();
Index: khtmlview.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v
retrieving revision 1.145
diff -u -3 -p -r1.145 khtmlview.h
--- khtmlview.h 2001/10/08 01:13:53 1.145
+++ khtmlview.h 2001/10/26 07:49:03
@@ -151,6 +151,19 @@ public:
void layout(bool force = false);
+ /**
+ * Get/set the CSS Media Type.
+ *
+ * Media type is set to "screen" for on-screen rendering and "print"
+ * during printing. Other media types lack the proper support in the
+ * renderer and are not activated. The DOM tree and the parser itself,
+ * however, properly handle other media types. To make them actually work
+ * you only need to enable the media type in the view and if necessary
+ * add the media type dependent changes to the renderer.
+ */
+ void setMediaType( const QString &medium );
+ QString mediaType() const;
+
signals:
void cleared();
@@ -223,6 +236,8 @@ private:
KHTMLPart *m_part;
KHTMLViewPrivate *d;
+
+ QString m_medium; // media type
};
#endif
Index: css/css_ruleimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_ruleimpl.cpp,v
retrieving revision 1.23
diff -u -3 -p -r1.23 css_ruleimpl.cpp
--- css/css_ruleimpl.cpp 2001/10/22 19:29:48 1.23
+++ css/css_ruleimpl.cpp 2001/10/26 07:49:03
@@ -108,12 +108,16 @@ CSSStyleDeclarationImpl *CSSFontFaceRule
// --------------------------------------------------------------------------
-CSSImportRuleImpl::CSSImportRuleImpl(StyleBaseImpl *parent, const DOM::DOMString \
&href,
- MediaListImpl *media)
+CSSImportRuleImpl::CSSImportRuleImpl( StyleBaseImpl *parent,
+ const DOM::DOMString &href,
+ const DOM::DOMString &media )
: CSSRuleImpl(parent)
{
m_type = CSSRule::IMPORT_RULE;
- m_lstMedia = media;
+
+ m_lstMedia = new MediaListImpl( this, media );
+ m_lstMedia->ref();
+
m_strHref = href;
m_styleSheet = 0;
@@ -184,21 +188,42 @@ bool CSSImportRuleImpl::isLoading()
CSSMediaRuleImpl::CSSMediaRuleImpl(StyleBaseImpl *parent)
- : CSSRuleImpl(parent)
+ : CSSRuleImpl( parent )
+{
+ m_type = CSSRule::MEDIA_RULE;
+ m_lstMedia = 0;
+ m_lstCSSRules = new CSSRuleListImpl();
+ m_lstCSSRules->ref();
+}
+
+CSSMediaRuleImpl::CSSMediaRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
+ const QChar *endP, const DOM::DOMString &media )
+: CSSRuleImpl( parent )
{
m_type = CSSRule::MEDIA_RULE;
- m_lstMedia = new MediaListImpl( this );
+ m_lstMedia = new MediaListImpl( this, media );
m_lstMedia->ref();
m_lstCSSRules = new CSSRuleListImpl();
m_lstCSSRules->ref();
+
+ // Parse CSS data
+ while( curP < endP )
+ {
+ //kdDebug( 6080 ) << "Style rule: '" << QString( curP, endP - curP )
+ // << "'" << endl;
+ CSSRuleImpl *rule = parseStyleRule( curP, endP );
+ rule->ref();
+ appendRule( rule );
+ while( curP < endP && *curP == QChar( ' ' ) )
+ curP++;
+ }
}
CSSMediaRuleImpl::~CSSMediaRuleImpl()
{
if( m_lstMedia )
m_lstMedia->deref();
- if( m_lstCSSRules )
- m_lstCSSRules->deref();
+ m_lstCSSRules->deref();
}
MediaListImpl *CSSMediaRuleImpl::media() const
@@ -211,6 +236,14 @@ CSSRuleListImpl *CSSMediaRuleImpl::cssRu
return m_lstCSSRules;
}
+unsigned long CSSMediaRuleImpl::appendRule( CSSRuleImpl *rule )
+{
+ if( rule )
+ return m_lstCSSRules->insertRule( rule, m_lstCSSRules->length() );
+ else
+ return 0;
+}
+
unsigned long CSSMediaRuleImpl::insertRule( const DOMString &rule,
unsigned long index )
{
@@ -218,12 +251,9 @@ unsigned long CSSMediaRuleImpl::insertRu
CSSRuleImpl *newRule = parseRule( curP, curP + rule.length() );
if( newRule )
- {
- newRule->ref();
return m_lstCSSRules->insertRule( newRule, index );
- }
- else
- return 0;
+
+ return 0;
}
void CSSMediaRuleImpl::deleteRule( unsigned long index )
@@ -231,6 +261,13 @@ void CSSMediaRuleImpl::deleteRule( unsig
m_lstCSSRules->deleteRule( index );
}
+CSSRuleListImpl::~CSSRuleListImpl()
+{
+ CSSRuleImpl* rule;
+ while ( ( rule = m_lstCSSRules.take( 0 ) ) )
+ rule->deref();
+}
+
// ---------------------------------------------------------------------------
CSSPageRuleImpl::CSSPageRuleImpl(StyleBaseImpl *parent)
@@ -353,22 +390,23 @@ CSSRuleImpl *CSSRuleListImpl::item ( uns
void CSSRuleListImpl::deleteRule ( unsigned long index )
{
- CSSRuleImpl *rule = m_lstCSSRules.at( index );
+ CSSRuleImpl *rule = m_lstCSSRules.take( index );
if( rule )
- {
- m_lstCSSRules.remove( index );
rule->deref();
- }
+ else
+ ; // ### Throw INDEX_SIZE_ERR exception here (TODO)
}
unsigned long CSSRuleListImpl::insertRule( CSSRuleImpl *rule,
unsigned long index )
{
- if( m_lstCSSRules.insert( index, rule ) )
+ if( rule && m_lstCSSRules.insert( index, rule ) )
+ {
+ rule->ref();
return index;
- else
- rule->deref(); // insertion failed
-
+ }
+
+ // ### Should throw INDEX_SIZE_ERR exception instead! (TODO)
return 0;
}
Index: css/css_ruleimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_ruleimpl.h,v
retrieving revision 1.13
diff -u -3 -p -r1.13 css_ruleimpl.h
--- css/css_ruleimpl.h 2001/10/07 13:12:19 1.13
+++ css/css_ruleimpl.h 2001/10/26 07:49:03
@@ -99,7 +99,8 @@ protected:
class CSSImportRuleImpl : public khtml::CachedObjectClient, public CSSRuleImpl
{
public:
- CSSImportRuleImpl(StyleBaseImpl *parent, const DOM::DOMString &href, \
MediaListImpl *media = 0); + CSSImportRuleImpl( StyleBaseImpl *parent, const \
DOM::DOMString &href, + const DOM::DOMString &media );
virtual ~CSSImportRuleImpl();
@@ -128,7 +129,9 @@ class CSSRuleList;
class CSSMediaRuleImpl : public CSSRuleImpl
{
public:
- CSSMediaRuleImpl(StyleBaseImpl *parent);
+ CSSMediaRuleImpl( StyleBaseImpl *parent );
+ CSSMediaRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
+ const QChar * endP, const DOM::DOMString &media );
virtual ~CSSMediaRuleImpl();
@@ -140,7 +143,10 @@ public:
virtual bool isMediaRule() { return true; }
protected:
MediaListImpl *m_lstMedia;
- CSSRuleListImpl *m_lstCSSRules;
+ CSSRuleListImpl *m_lstCSSRules;
+
+ /* Not part of the DOM */
+ unsigned long appendRule( CSSRuleImpl *rule );
};
@@ -201,30 +207,25 @@ public:
~CSSUnknownRuleImpl();
- virtual bool isUnknownRule() { return true; }
+ virtual bool isUnknownRule() { return true; }
};
+
class CSSRuleListImpl : public DomShared
{
public:
CSSRuleListImpl();
+ ~CSSRuleListImpl();
unsigned long length() const;
CSSRuleImpl *item ( unsigned long index );
- /**
- * Internal API, _NOT_ to be exposed outside! (Used by CSSMediaRuleImpl)
- */
+ /* not part of the DOM */
unsigned long insertRule ( CSSRuleImpl *rule, unsigned long index );
void deleteRule ( unsigned long index );
protected:
-#if QT_VERSION < 300
QList<CSSRuleImpl> m_lstCSSRules;
-#else
- QPtrList<CSSRuleImpl> m_lstCSSRules;
-#endif
-
};
}; // namespace
Index: css/css_stylesheetimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_stylesheetimpl.cpp,v
retrieving revision 1.32
diff -u -3 -p -r1.32 css_stylesheetimpl.cpp
--- css/css_stylesheetimpl.cpp 2001/09/24 15:31:58 1.32
+++ css/css_stylesheetimpl.cpp 2001/10/26 07:49:03
@@ -119,6 +119,15 @@ MediaListImpl *StyleSheetImpl::media() c
return m_media;
}
+void StyleSheetImpl::setMedia( MediaListImpl *media )
+{
+ if( m_media )
+ m_media->deref();
+ m_media = media;
+ if( m_media )
+ m_media->ref();
+}
+
// -----------------------------------------------------------------------
@@ -362,15 +371,34 @@ MediaListImpl::MediaListImpl(CSSStyleShe
{
}
+MediaListImpl::MediaListImpl( CSSStyleSheetImpl *parentSheet,
+ const DOMString &media )
+ : StyleBaseImpl( parentSheet )
+{
+ setMediaText( media );
+}
+
MediaListImpl::MediaListImpl(CSSRuleImpl *parentRule)
: StyleBaseImpl(parentRule)
{
}
+MediaListImpl::MediaListImpl( CSSRuleImpl *parentRule, const DOMString &media )
+ : StyleBaseImpl(parentRule)
+{
+ setMediaText( media );
+}
+
MediaListImpl::~MediaListImpl()
{
}
+bool MediaListImpl::contains( const DOMString &medium ) const
+{
+ return m_lstMedia.count() == 0 || m_lstMedia.contains( medium ) ||
+ m_lstMedia.contains( "all" );
+}
+
CSSStyleSheetImpl *MediaListImpl::parentStyleSheet() const
{
if( m_parent->isCSSStyleSheet() ) return static_cast<CSSStyleSheetImpl \
*>(m_parent); @@ -388,7 +416,7 @@ unsigned long MediaListImpl::length() co
return m_lstMedia.count();
}
-DOMString MediaListImpl::item( unsigned long index )
+DOMString MediaListImpl::item( unsigned long index ) const
{
return m_lstMedia[index];
}
@@ -424,5 +452,9 @@ void MediaListImpl::setMediaText(const D
QString val = value.string();
QStringList list = QStringList::split( ',', value.string() );
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
- m_lstMedia.append( DOMString( (*it).stripWhiteSpace() ) );
+ {
+ DOMString medium = (*it).stripWhiteSpace();
+ if( medium != "" )
+ m_lstMedia.append( medium );
+ }
}
Index: css/css_stylesheetimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_stylesheetimpl.h,v
retrieving revision 1.19
diff -u -3 -p -r1.19 css_stylesheetimpl.h
--- css/css_stylesheetimpl.h 2001/10/22 19:29:48 1.19
+++ css/css_stylesheetimpl.h 2001/10/26 07:49:03
@@ -73,6 +73,7 @@ public:
DOM::DOMString href() const;
DOM::DOMString title() const;
MediaListImpl *media() const;
+ void setMedia( MediaListImpl *media );
protected:
DOM::NodeImpl *m_parentNode;
@@ -140,8 +141,11 @@ public:
class MediaListImpl : public StyleBaseImpl
{
public:
- MediaListImpl(CSSStyleSheetImpl *parentSheet);
- MediaListImpl(CSSRuleImpl *parentRule);
+ MediaListImpl( CSSStyleSheetImpl *parentSheet );
+ MediaListImpl( CSSStyleSheetImpl *parentSheet,
+ const DOM::DOMString &media );
+ MediaListImpl( CSSRuleImpl *parentRule );
+ MediaListImpl( CSSRuleImpl *parentRule, const DOM::DOMString &media );
virtual ~MediaListImpl();
@@ -150,12 +154,22 @@ public:
CSSStyleSheetImpl *parentStyleSheet() const;
CSSRuleImpl *parentRule() const;
unsigned long length() const;
- DOM::DOMString item ( unsigned long index );
+ DOM::DOMString item ( unsigned long index ) const;
void deleteMedium ( const DOM::DOMString &oldMedium );
void appendMedium ( const DOM::DOMString &newMedium );
DOM::DOMString mediaText() const;
void setMediaText(const DOM::DOMString &value);
+
+ /**
+ * Check if the list contains either the requested medium, or the
+ * catch-all "all" media type. Returns true when found, false otherwise.
+ * Since not specifying media types should be treated as "all" according
+ * to DOM specs, an empty list always returns true.
+ *
+ * _NOT_ part of the DOM!
+ */
+ bool contains( const DOM::DOMString &medium ) const;
protected:
QValueList<DOM::DOMString> m_lstMedia;
Index: css/cssparser.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/cssparser.cpp,v
retrieving revision 1.171
diff -u -3 -p -r1.171 cssparser.cpp
--- css/cssparser.cpp 2001/10/24 18:29:24 1.171
+++ css/cssparser.cpp 2001/10/26 07:49:03
@@ -236,13 +236,13 @@ StyleBaseImpl::parseAtRule(const QChar *
if(*curP != ';')
curP = parseToChar(startP, endP, ';', false, true);
if(!curP) return 0;
- QString media(startP, curP - startP);
- media = media.stripWhiteSpace();
+
+ DOMString mediaList = DOMString( startP, curP - startP);
// ### check if at the beginning of the stylesheet (no style rule
// before the import rule)
#ifdef CSS_DEBUG
- kdDebug( 6080 ) << "at rule: url = '" << url.string()
- << "' media = '" << media << "'"<< endl;
+ kdDebug( 6080 ) << "import rule = " << url.string() << ", mediaList = "
+ << mediaList.string << endl;
#endif
// ignore block following @import rule
if( *curP == '{' ) {
@@ -251,12 +251,9 @@ StyleBaseImpl::parseAtRule(const QChar *
if(curP)
curP++;
}
- // ### only media="", "screen and "all" are imported for the moment...
- // ### add at least "print" here once the MediaList class is implemented
- if( !media.isEmpty() && !(media.contains("all") || media.contains("screen") \
) )
- return 0;
if(!this->isCSSStyleSheet()) return 0;
- return new CSSImportRuleImpl(this, url, 0);
+
+ return new CSSImportRuleImpl( this, url, mediaList );
}
else if(rule == "charset")
{
@@ -284,7 +281,7 @@ StyleBaseImpl::parseAtRule(const QChar *
curP = parseToChar(startP, endP, '{', false);
//qDebug("mediaList = '%s'", mediaList.latin1() );
if ( !curP || curP >= endP ) return 0;
- QString mediaList = QString( startP, curP - startP);
+ DOMString mediaList = DOMString( startP, curP - startP);
curP++;
startP = curP;
if ( curP >= endP ) return 0;
@@ -292,10 +289,10 @@ StyleBaseImpl::parseAtRule(const QChar *
if ( !curP || startP >= curP )
return 0;
#ifdef CSS_DEBUG
- kdDebug( 6080 ) << "media rule = " << QString(startP, curP - startP) << \
endl; + kdDebug( 6080 ) << "media rule = " << QString(startP, curP - startP)
+ << ", mediaList = " << mediaList.string() << endl;
#endif
- if ( mediaList.contains( "screen" ) || mediaList.contains( "all" ) )
- return parseStyleRule(startP, curP);
+ return new CSSMediaRuleImpl( this, startP, curP, mediaList );
}
else if(rule == "page")
{
Index: css/cssstyleselector.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.177
diff -u -3 -p -r1.177 cssstyleselector.cpp
--- css/cssstyleselector.cpp 2001/09/25 20:26:27 1.177
+++ css/cssstyleselector.cpp 2001/10/26 07:49:04
@@ -92,14 +92,21 @@ CSSStyleSelector::CSSStyleSelector(Docum
userSheet->parseString( DOMString( doc->userStyleSheet() ) );
userStyle = new CSSStyleSelectorList();
- userStyle->append(userSheet);
+ userStyle->append( userSheet, doc->view()->mediaType() );
}
// add stylesheets from document
authorStyle = new CSSStyleSelectorList();
StyleSheetListImpl* ss = doc->styleSheets();
- for ( QListIterator<StyleSheetImpl> it( ss->styleSheets ); it.current(); ++it )
- authorStyle->append( it.current());
+
+ QListIterator<StyleSheetImpl> it( ss->styleSheets );
+ for ( ; it.current(); ++it )
+ {
+ CSSStyleSheetImpl *curSheet =
+ dynamic_cast<CSSStyleSheetImpl *>( it.current() );
+ if( curSheet )
+ authorStyle->append( curSheet, doc->view()->mediaType() );
+ }
buildLists();
@@ -123,12 +130,12 @@ CSSStyleSelector::CSSStyleSelector(Docum
//kdDebug() << "CSSStyleSelector::CSSStyleSelector encoded url " << \
encodedurl.path << endl; }
-CSSStyleSelector::CSSStyleSelector(StyleSheetImpl *sheet)
+CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
{
if(!defaultStyle) loadDefaultStyle();
authorStyle = new CSSStyleSelectorList();
- authorStyle->append(sheet);
+ authorStyle->append( sheet, sheet->doc()->view()->mediaType() );
}
CSSStyleSelector::~CSSStyleSelector()
@@ -139,9 +146,9 @@ CSSStyleSelector::~CSSStyleSelector()
delete userSheet;
}
-void CSSStyleSelector::addSheet(StyleSheetImpl *sheet)
+void CSSStyleSelector::addSheet( CSSStyleSheetImpl *sheet )
{
- authorStyle->append(sheet);
+ authorStyle->append( sheet, sheet->doc()->view()->mediaType() );
}
void CSSStyleSelector::loadDefaultStyle(const KHTMLSettings *s)
@@ -166,7 +173,7 @@ void CSSStyleSelector::loadDefaultStyle(
defaultSheet->parseString( str );
defaultStyle = new CSSStyleSelectorList();
- defaultStyle->append(defaultSheet);
+ defaultStyle->append( defaultSheet );
//kdDebug() << "CSSStyleSelector: default style has " << defaultStyle->count() \
<< " elements"<< endl; }
@@ -743,11 +750,16 @@ CSSStyleSelectorList::~CSSStyleSelectorL
{
}
-void CSSStyleSelectorList::append(StyleSheetImpl *sheet)
+void CSSStyleSelectorList::append( CSSStyleSheetImpl *sheet,
+ const DOMString &medium )
{
-
if(!sheet || !sheet->isCSSStyleSheet()) return;
+ // No media implies "all", but if a medialist exists it must
+ // contain our current medium
+ if( sheet->media() && !sheet->media()->contains( medium ) )
+ return; // style sheet not applicable for this medium
+
int len = sheet->length();
for(int i = 0; i< len; i++)
@@ -767,11 +779,63 @@ void CSSStyleSelectorList::append(StyleS
else if(item->isImportRule())
{
CSSImportRuleImpl *import = static_cast<CSSImportRuleImpl *>(item);
- // ### check media type
- StyleSheetImpl *importedSheet = import->styleSheet();
- append(importedSheet);
+
+ //kdDebug( 6080 ) << "@import: Media: "
+ // << import->media()->mediaText().string() << endl;
+
+ if( !import->media() || import->media()->contains( medium ) )
+ {
+ CSSStyleSheetImpl *importedSheet = import->styleSheet();
+ append( importedSheet, medium );
+ }
+ }
+ else if( item->isMediaRule() )
+ {
+ CSSMediaRuleImpl *r = static_cast<CSSMediaRuleImpl *>( item );
+ CSSRuleListImpl *rules = r->cssRules();
+
+ //DOMString mediaText = media->mediaText();
+ //kdDebug( 6080 ) << "@media: Media: "
+ // << r->media()->mediaText().string() << endl;
+
+ if( ( !r->media() || r->media()->contains( medium ) ) && rules)
+ {
+ // Traverse child elements of the @import rule. Since
+ // many elements are not allowed as child we do not use
+ // a recursive call to append() here
+ for( int j = 0; j < rules->length(); j++ )
+ {
+ //kdDebug( 6080 ) << "*** Rule #" << j << endl;
+
+ CSSRuleImpl *childItem = rules->item( j );
+ if( childItem->isStyleRule() )
+ {
+ // It is a StyleRule, so append it to our list
+ CSSStyleRuleImpl *styleRule =
+ static_cast<CSSStyleRuleImpl *>( childItem );
+
+ QList<CSSSelector> *s = styleRule->selector();
+ for( int j = 0; j < ( int ) s->count(); j++ )
+ {
+ CSSOrderedRule *orderedRule = new CSSOrderedRule(
+ styleRule, s->at( j ), count() );
+ QList<CSSOrderedRule>::append( orderedRule );
+ }
+ }
+ else
+ {
+ //kdDebug( 6080 ) << "Ignoring child rule of "
+ // "ImportRule: rule is not a StyleRule!" << endl;
+ }
+ } // for rules
+ } // if rules
+ else
+ {
+ //kdDebug( 6080 ) << "CSSMediaRule not rendered: "
+ // << "rule empty or wrong medium!" << endl;
+ }
}
- // ### include media, import rules and other
+ // ### include other rules
}
}
Index: css/cssstyleselector.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/cssstyleselector.h,v
retrieving revision 1.20
diff -u -3 -p -r1.20 cssstyleselector.h
--- css/cssstyleselector.h 2001/10/07 13:12:19 1.20
+++ css/cssstyleselector.h 2001/10/26 07:49:04
@@ -107,15 +107,15 @@ namespace khtml
* Also takes into account special cases for HTML documents,
* including the defaultStyle (which is html only)
*/
- CSSStyleSelector(DOM::DocumentImpl *doc);
+ CSSStyleSelector( DOM::DocumentImpl *doc );
/**
* same as above but for a single stylesheet.
*/
- CSSStyleSelector(DOM::StyleSheetImpl *sheet);
+ CSSStyleSelector( DOM::CSSStyleSheetImpl *sheet );
virtual ~CSSStyleSelector();
- void addSheet(DOM::StyleSheetImpl *sheet);
+ void addSheet( DOM::CSSStyleSheetImpl *sheet );
static void loadDefaultStyle(const KHTMLSettings *s = 0);
static void clear();
@@ -229,7 +229,8 @@ namespace khtml
CSSStyleSelectorList();
virtual ~CSSStyleSelectorList();
- void append(DOM::StyleSheetImpl *sheet);
+ void append( DOM::CSSStyleSheetImpl *sheet,
+ const DOM::DOMString &medium = "screen" );
void collect( QList<DOM::CSSSelector> *selectorList, CSSOrderedPropertyList \
*propList, Source regular, Source important );
Index: html/html_headimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_headimpl.cpp,v
retrieving revision 1.76
diff -u -3 -p -r1.76 html_headimpl.cpp
--- html/html_headimpl.cpp 2001/09/11 13:05:54 1.76
+++ html/html_headimpl.cpp 2001/10/26 07:49:04
@@ -180,10 +180,16 @@ void HTMLLinkElementImpl::parseAttribute
void HTMLLinkElementImpl::setStyleSheet(const DOM::DOMString &url, const \
DOM::DOMString &sheetStr) {
// kdDebug( 6030 ) << "HTMLLinkElement::setStyleSheet()" << endl;
+// kdDebug( 6030 ) << "**** current medium: " << m_media << endl;
+
if( m_sheet ) return;
m_sheet = new CSSStyleSheetImpl(this, url);
m_sheet->ref();
m_sheet->parseString(sheetStr);
+
+ MediaListImpl *media = new MediaListImpl( m_sheet, m_media );
+ m_sheet->setMedia( media );
+
m_loading = false;
if ( sheet() ) getDocument()->createSelector();
@@ -205,15 +211,9 @@ void HTMLLinkElementImpl::sheetLoaded()
StyleSheetImpl *HTMLLinkElementImpl::sheet() const
{
- if ( khtml::printpainter ) {
- // we're currently printing, return all and print style sheets
- if( m_media.isNull() || m_media.contains("all") || m_media.contains("print") \
)
- return m_sheet;
- } else {
- if( m_media.isNull() || m_media.contains("screen") || \
m_media.contains("all") )
- return m_sheet;
- }
- return 0;
+ //kdDebug( 6030 ) << "**** HTMLLinkElementImpl::sheet()" << endl;
+
+ return m_sheet;
}
Index: html/html_headimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_headimpl.h,v
retrieving revision 1.27
diff -u -3 -p -r1.27 html_headimpl.h
--- html/html_headimpl.h 2001/10/07 13:12:19 1.27
+++ html/html_headimpl.h 2001/10/26 07:49:04
@@ -39,6 +39,7 @@ namespace DOM {
class DOMString;
class HTMLFormElementImpl;
class StyleSheetImpl;
+class CSSStyleSheetImpl;
class HTMLBaseElementImpl : public HTMLElementImpl
{
@@ -86,7 +87,7 @@ public:
protected:
khtml::CachedCSSStyleSheet *m_cachedSheet;
- StyleSheetImpl *m_sheet;
+ CSSStyleSheetImpl *m_sheet;
DOMString m_url;
DOMString m_type;
QString m_media;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic