Commit 0aed4d6d authored by gramps's avatar gramps

Merged changes from KDE 2.2.1 distribution


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dba58ac9
......@@ -39,7 +39,7 @@ noinst_HEADERS = nodes.h lexer.h regexp.h internal.h collector.h \
number_object.h date_object.h regexp_object.h error_object.h \
debugger.h
libkjs_la_LDFLAGS = -version-info 1:0 -no-undefined $(USER_LDFLAGS)
libkjs_la_LDFLAGS = -version-info 1:0 -no-undefined $(USER_LDFLAGS) $(all_libraries)
libkjs_la_LIBADD = -lm $(LIBPCRE)
parser: $(srcdir)/grammar.y
......
This diff is collapsed.
......@@ -130,9 +130,7 @@ DOMString khtml::parseURL(const DOMString &url)
int nl = 0;
for(int k = o; k < o+l; k++)
if(i->s[k] == '\\')
j->s[nl++] = '/';
else if(i->s[k].unicode() > '\r')
if(i->s[k].unicode() > '\r')
j->s[nl++] = i->s[k];
j->l = nl;
......
......@@ -414,6 +414,9 @@ StyleBaseImpl::parseSelector2(const QChar *curP, const QChar *endP,
#endif
cs->match = CSSSelector::Set;
endVal = closebracket + 1;
// ### fixme we ignore everything after [..]
if( endVal == endP )
endVal = 0;
}
else
{
......@@ -1587,7 +1590,7 @@ bool StyleBaseImpl::parseValue( const QChar *curP, const QChar *endP, int propId
value = khtml::parseURL(value);
parsedValue = new CSSImageValueImpl(value, baseUrl(), this);
#ifdef CSS_DEBUG
kdDebug( 6080 ) << "image, url=" << value.string() << " base=" << baseUrl().string() << endl;
kdDebug( 6080 ) << "image, url=" << value.string() << " base=" << baseURL().string() << endl;
#endif
}
}
......
......@@ -62,9 +62,7 @@ using namespace DOM;
#include <qintcache.h>
CSSStyleSelectorList *CSSStyleSelector::defaultStyle = 0;
CSSStyleSelectorList *CSSStyleSelector::userStyle = 0;
CSSStyleSheetImpl *CSSStyleSelector::defaultSheet = 0;
CSSStyleSheetImpl *CSSStyleSelector::userSheet = 0;
enum PseudoState { PseudoUnknown, PseudoNone, PseudoLink, PseudoVisited};
static PseudoState pseudoState;
......@@ -84,6 +82,17 @@ CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
selectors = 0;
selectorCache = 0;
properties = 0;
userStyle = 0;
userSheet = 0;
if ( !doc->userStyleSheet().isEmpty() ) {
userSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl *)0);
userSheet->parseString( DOMString( doc->userStyleSheet() ) );
userStyle = new CSSStyleSelectorList();
userStyle->append(userSheet);
}
// add stylesheets from document
authorStyle = new CSSStyleSelectorList();
......@@ -124,6 +133,8 @@ CSSStyleSelector::~CSSStyleSelector()
{
clearLists();
delete authorStyle;
delete userStyle;
delete userSheet;
}
void CSSStyleSelector::addSheet(StyleSheetImpl *sheet)
......@@ -131,18 +142,6 @@ void CSSStyleSelector::addSheet(StyleSheetImpl *sheet)
authorStyle->append(sheet);
}
void CSSStyleSelector::setUserStyle(const DOM::DOMString &str)
{
if(userStyle) delete userStyle;
if(userSheet) delete userSheet;
userSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl *)0);
userSheet->parseString( str );
userStyle = new CSSStyleSelectorList();
userStyle->append(userSheet);
}
void CSSStyleSelector::loadDefaultStyle(const KHTMLSettings *s)
{
if(defaultStyle) return;
......@@ -172,17 +171,12 @@ void CSSStyleSelector::loadDefaultStyle(const KHTMLSettings *s)
void CSSStyleSelector::clear()
{
delete defaultStyle;
delete userStyle;
delete defaultSheet;
delete userSheet;
defaultStyle = 0;
userStyle = 0;
defaultSheet = 0;
userSheet = 0;
}
static bool strictParsing;
//static QList<RenderStyle>* styleElementCache = 0;
RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
{
......@@ -266,6 +260,7 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
while( ordprop ) {
RenderStyle *pseudoStyle;
pseudoStyle = style->addPseudoStyle(ordprop->pseudoId);
if ( pseudoStyle )
applyRule(pseudoStyle, ordprop->prop, e);
ordprop = pseudoProps->next();
......
......@@ -116,9 +116,8 @@ namespace khtml
virtual ~CSSStyleSelector();
void addSheet(DOM::StyleSheetImpl *sheet);
static void loadDefaultStyle(const KHTMLSettings *s = 0);
static void setUserStyle(const DOM::DOMString &sheet);
static void clear();
virtual RenderStyle *styleForElement(DOM::ElementImpl *e, int state = None );
......@@ -146,9 +145,9 @@ namespace khtml
static DOM::CSSStyleSheetImpl *defaultSheet;
static CSSStyleSelectorList *defaultStyle;
static DOM::CSSStyleSheetImpl *userSheet;
static CSSStyleSelectorList *userStyle;
CSSStyleSelectorList *authorStyle;
CSSStyleSelectorList *userStyle;
DOM::CSSStyleSheetImpl *userSheet;
public: // we need to make the enum public for SelectorCache
enum SelectorState {
......@@ -168,7 +167,6 @@ namespace khtml
unsigned int selectors_size;
DOM::CSSSelector **selectors;
SelectorCache *selectorCache;
unsigned int properties_size;
CSSOrderedProperty **properties;
QArray<CSSOrderedProperty> inlineProps;
......@@ -193,7 +191,7 @@ namespace khtml
{
priority = (!first << 30) | (source << 24) | specificity;
}
DOM::CSSProperty *prop;
RenderStyle::PseudoId pseudoId;
unsigned int selector;
......
......@@ -289,6 +289,8 @@ bool DOM::operator==( const DOMString &a, const QString &b )
bool DOM::operator==( const DOMString &a, const char *b )
{
if ( !b ) return a.isNull();
if ( a.isNull() ) return false;
unsigned int blen = strlen(b);
if(a.length() != blen) return false;
......
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
......
......@@ -355,6 +355,8 @@ KJSO KJS::HTMLElement::tryGet(const UString &p) const
else if (p == "link") return getString(body.link());
else if (p == "text") return getString(body.text());
else if (p == "vLink") return getString(body.vLink());
else if (p == "scrollHeight" ) return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsHeight() : 0);
else if (p == "scrollWidth" ) return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsWidth() : 0);
}
break;
case ID_FORM: {
......
......@@ -302,7 +302,7 @@ DOM::NodeFilter KJS::toNodeFilter(const KJSO& obj)
// -------------------------------------------------------------------------
JSNodeFilter::JSNodeFilter(KJSO _filter) : CustomNodeFilter()
JSNodeFilter::JSNodeFilter(KJSO _filter) : DOM::CustomNodeFilter()
{
filter = _filter;
}
......
......@@ -263,14 +263,19 @@ void HTMLFrameElementImpl::parseAttribute(AttrImpl *attr)
void HTMLFrameElementImpl::attach()
{
setStyle(ownerDocument()->styleSelector()->styleForElement( this ));
KHTMLView* w = ownerDocument()->view();
// limit to how deep we can nest frames
KHTMLPart *part = w->part();
int depth = 0;
while ((part = part->parentPart()))
depth++;
if (depth > 10)
if (depth > 6 || url.isNull()) {
style()->setDisplay( NONE );
return;
}
// inherit default settings from parent frameset
HTMLElementImpl* node = static_cast<HTMLElementImpl*>(parentNode());
......@@ -286,7 +291,6 @@ void HTMLFrameElementImpl::attach()
node = static_cast<HTMLElementImpl*>(node->parentNode());
}
setStyle(ownerDocument()->styleSelector()->styleForElement( this ));
khtml::RenderObject *r = _parent->renderer();
// ignore display: none for this element!
......@@ -654,16 +658,18 @@ void HTMLIFrameElementImpl::parseAttribute(AttrImpl *attr )
void HTMLIFrameElementImpl::attach()
{
setStyle(ownerDocument()->styleSelector()->styleForElement( this ));
KHTMLView* w = ownerDocument()->view();
// limit to how deep we can nest frames
KHTMLPart *part = w->part();
int depth = 0;
while ((part = part->parentPart()))
depth++;
if (depth > 10)
return;
setStyle(ownerDocument()->styleSelector()->styleForElement( this ));
if (depth > 6) {
style()->setDisplay( NONE );
return;
}
khtml::RenderObject *r = _parent->renderer();
......
......@@ -1274,6 +1274,7 @@ void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT,2);
else
dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT,1);
me->setDefaultHandled();
}
if ((evt->id() == EventImpl::DOMACTIVATE_EVENT) &&
......
......@@ -306,7 +306,7 @@ void HTMLMetaElementImpl::attach()
ownerDocument()->docLoader()->setExpireDate(expire_date);
}
}
else if(strcasecmp(_equiv, "pragma") == 0 && !_content.isNull())
else if( (strcasecmp(_equiv, "pragma") == 0 || strcasecmp(_equiv, "cache-control") == 0 ) && !_content.isNull() )
{
QString str = _content.string().lower().stripWhiteSpace();
KURL url = v->part()->url();
......
......@@ -190,11 +190,13 @@ void KHTMLParser::parseToken(Token *t)
kdDebug( 6035 ) << "Unknown tag!! tagID = " << t->id << endl;
return;
}
if(discard_until)
{
if(discard_until) {
if(t->id == discard_until)
discard_until = 0;
return;
// do not skip </iframe>
if ( discard_until || current->id() + ID_CLOSE_TAG != t->id )
return;
}
#ifdef PARSER_DEBUG
......@@ -559,7 +561,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
( !checkChild( ID_TR, id ) && ( node->id() == ID_THEAD || node->id() == ID_TBODY || node->id() == ID_TFOOT ) &&
parent->id() == ID_TABLE ) )
{
node = parentparent;
node = ( node->id() == ID_TR ) ? parentparent : parent;
NodeImpl *parent = node->parentNode();
int exceptioncode = 0;
NodeImpl *container = new HTMLGenericElementImpl( document, ID__KONQBLOCK );
......@@ -746,6 +748,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
// a bit a special case, since the frame is inlined...
case ID_IFRAME:
n = new HTMLIFrameElementImpl(document);
discard_until = ID_IFRAME+ID_CLOSE_TAG;
break;
// form elements
......@@ -876,7 +879,6 @@ NodeImpl *KHTMLParser::getElement(Token* t)
// anchor
case ID_A:
popBlock(ID_A);
n = new HTMLAnchorElementImpl(document);
break;
......
This diff is collapsed.
......@@ -163,17 +163,17 @@ protected:
void reset();
void addPending();
void processToken();
void addListing(khtml::DOMStringIt list);
void processListing(khtml::DOMStringIt list);
void parseComment(khtml::DOMStringIt &str);
void parseText(khtml::DOMStringIt &str);
void parseStyle(khtml::DOMStringIt &str);
void parseScript(khtml::DOMStringIt &str);
void parseListing(khtml::DOMStringIt &str);
void parseSpecial(khtml::DOMStringIt &str, bool begin);
void parseTag(khtml::DOMStringIt &str);
void parseEntity(khtml::DOMStringIt &str, QChar *&dest, bool start = false);
void parseProcessingInstruction(khtml::DOMStringIt &str);
void scriptHandler();
void scriptExecution(const QString& script);
void addPendingSource();
// check if we have enough space in the buffer.
......@@ -264,10 +264,10 @@ protected:
SearchSemicolon
} Entity;
QChar EntityChar;
// are we in a <script> ... </script block
bool script;
// Flag to say that we are just parsing an attribute
bool parseAttr;
QChar EntityChar;
// Are we in a <pre> ... </pre> block
bool pre;
......@@ -275,9 +275,6 @@ protected:
// if 'pre == true' we track in which column we are
int prePos;
// Are we in a <script> ... </script> block
bool script;
// Are we in a <style> ... </style> block
bool style;
......@@ -311,13 +308,19 @@ protected:
int scriptCodeSize;
// Maximal size that can be stored in @ref #scriptCode
int scriptCodeMaxSize;
// resync point of script code size
int scriptCodeResync;
// Stores characters if we are scanning for a string like "</script>"
QChar searchBuffer[ 10 ];
// Counts where we are in the string we are scanning for
int searchCount;
// The string we are searching for
const QChar *searchFor;
// the stopper string
const char* searchStopper;
// the stopper len
int searchStopperLen;
// true if we are waiting for an external script (<SCRIPT SRC=...) to load, i.e.
// we don't do any parsing while this is true
bool loadingExtScript;
......
[Desktop Entry]
Type=Service
Comment=Embeddable HTML viewing component
Comment[af]=INLEGBARE HTML AANSIG KOMPONENT
Comment[az]=Hopdurula Bilən HTML nümayiş vasitəsi
Comment[bg]=Елемент за преглед на вградени HTML
Comment[br]=Parzh HTML gweler enframmus
......@@ -45,8 +44,8 @@ Comment[ta]=¯ð¦À¡¾¢ì¸ÅøÄ HTML ¸¡ðº¢ì ÜÚ
Comment[tr]=Gömülebilir HTML görüntüleme aracı
Comment[uk]=Вбудований копмонент-переглядач HTML
Comment[vi]=Component đềExem HTML có thềEembedd được
Comment[xh]=Inxenye yemboniselo elungisiweyo ye HTML
Comment[zh_CN.GB2312]=嵌入的 HTML 查看部件
Comment[zh_TW.Big5]=內建式 HTML 檢視元件
MimeType=text/html;text/xml;
Icon=konqueror
Name=KHTML
......
......@@ -151,7 +151,6 @@ public:
m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
m_bClearing = false;
m_bCleared = false;
m_userSheet = QString::null;
m_fontBase = 0;
m_bDnd = true;
m_startOffset = m_endOffset = 0;
......@@ -305,9 +304,6 @@ public:
KParts::PartManager *m_manager;
DOM::DOMString m_userSheet;
DOM::DOMString m_userSheetUrl;
QString m_popupMenuXML;
int m_fontBase;
......@@ -323,6 +319,7 @@ public:
const char *submitAction;
QString submitUrl;
QByteArray submitFormData;
QString target;
QString submitContentType;
QString submitBoundary;
};
......@@ -380,12 +377,10 @@ namespace khtml {
class PartStyleSheetLoader : public CachedObjectClient
{
public:
PartStyleSheetLoader(KHTMLPart *part, KHTMLPartPrivate *priv, DOM::DOMString url, DocLoader */*docLoader*/)
PartStyleSheetLoader(KHTMLPart *part, DOM::DOMString url, DocLoader* dl)
{
m_part = part;
m_priv = priv;
// the "foo" is needed, so that the docloader for the empty document doesn't cancel this request.
m_cachedSheet = Cache::requestStyleSheet(0, url, DOMString("foo") );
m_cachedSheet = dl->requestStyleSheet( url, part->baseURL().url(), QString::null );
if (m_cachedSheet)
m_cachedSheet->ref( this );
}
......@@ -393,20 +388,14 @@ namespace khtml {
{
if ( m_cachedSheet ) m_cachedSheet->deref(this);
}
virtual void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet)
virtual void setStyleSheet(const DOM::DOMString&, const DOM::DOMString &sheet)
{
if ( m_part )
{
m_priv->m_userSheet = sheet;
m_priv->m_userSheetUrl = url;
}
khtml::CSSStyleSelector::setUserStyle( sheet );
if ( m_part && m_priv->m_doc )
m_priv->m_doc->applyChanges();
if ( m_part )
m_part->setUserStyleSheet( sheet.string() );
delete this;
}
QGuardedPtr<KHTMLPart> m_part;
KHTMLPartPrivate *m_priv;
khtml::CachedCSSStyleSheet *m_cachedSheet;
};
};
......@@ -511,10 +500,6 @@ void KHTMLPart::init( KHTMLView *view, GUIProfile prof )
d->m_bJavaEnabled = KHTMLFactory::defaultHTMLSettings()->isJavaEnabled();
d->m_bPluginsEnabled = KHTMLFactory::defaultHTMLSettings()->isPluginsEnabled();
QString userStyleSheet = KHTMLFactory::defaultHTMLSettings()->userStyleSheet();
if ( !userStyleSheet.isEmpty() )
setUserStyleSheet( KURL( userStyleSheet ) );
connect( this, SIGNAL( completed() ),
this, SLOT( updateActions() ) );
connect( this, SIGNAL( completed( bool ) ),
......@@ -627,7 +612,7 @@ bool KHTMLPart::openURL( const KURL &url )
// operation and d) the caller did not request to reload the page we try to
// be smart and instead of reloading the whole document we just jump to the
// request html anchor
if ( d->m_frames.count() == 0 &&
if ( d->m_frames.count() == 0 && d->m_doc && d->m_bComplete &&
urlcmp( url.url(), m_url.url(), true, true ) && !args.doPost() && !args.reload )
{
kdDebug( 6050 ) << "KHTMLPart::openURL now m_url = " << url.url() << endl;
......@@ -645,7 +630,12 @@ bool KHTMLPart::openURL( const KURL &url )
emitLoadEvent();
kdDebug( 6050 ) << "completed..." << endl;
emit completed();
if ( !d->m_redirectURL.isEmpty() )
{
emit completed(true);
}
else emit completed();
return true;
}
......@@ -1377,6 +1367,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
d->m_doc->setURL( m_url.url() );
setAutoloadImages( KHTMLFactory::defaultHTMLSettings()->autoLoadImages() );
QString userStyleSheet = KHTMLFactory::defaultHTMLSettings()->userStyleSheet();
if ( !userStyleSheet.isEmpty() )
setUserStyleSheet( KURL( userStyleSheet ) );
d->m_doc->setRestoreState(args.docState);
d->m_doc->open();
......@@ -1641,7 +1634,6 @@ void KHTMLPart::checkEmitLoadEvent()
{
if ( d->m_bLoadEventEmitted || d->m_bParsing )
return;
kdDebug(6050) << "KHTMLPart::checkEmitLoadEvent " << this << endl;
ConstFrameIt it = d->m_frames.begin();
ConstFrameIt end = d->m_frames.end();
for (; it != end; ++it )
......@@ -1653,6 +1645,7 @@ void KHTMLPart::checkEmitLoadEvent()
void KHTMLPart::emitLoadEvent()
{
d->m_bLoadEventEmitted = true;
kdDebug(6050) << "KHTMLPart::emitLoadEvent " << this << endl;
if ( d->m_doc && d->m_doc->isHTMLDocument() ) {
HTMLDocumentImpl* hdoc = static_cast<HTMLDocumentImpl*>( d->m_doc );
......@@ -1731,6 +1724,7 @@ void KHTMLPart::slotRedirect()
QString target;
u = splitUrlTarget( u, &target );
KParts::URLArgs args;
args.reload = true;
args.setLockHistory( true );
urlSelected( u, 0, 0, target, args );
}
......@@ -1791,21 +1785,20 @@ QString KHTMLPart::encoding()
void KHTMLPart::setUserStyleSheet(const KURL &url)
{
d->m_userSheetUrl = DOMString();
d->m_userSheet = DOMString();
(void) new khtml::PartStyleSheetLoader(this, d, url.url(), d->m_doc ? d->m_doc->docLoader() : 0);
if ( d->m_doc && d->m_doc->docLoader() )
(void) new khtml::PartStyleSheetLoader(this, url.url(), d->m_doc->docLoader());
}
void KHTMLPart::setUserStyleSheet(const QString &styleSheet)
{
d->m_userSheet = styleSheet;
d->m_userSheetUrl = DOMString();
khtml::CSSStyleSelector::setUserStyle( styleSheet );
if ( d->m_doc )
d->m_doc->setUserStyleSheet( styleSheet );
}
bool KHTMLPart::gotoAnchor( const QString &name )
{
if (!d->m_doc)
return false;
HTMLCollectionImpl *anchors =
new HTMLCollectionImpl( d->m_doc, HTMLCollectionImpl::DOC_ANCHORS);
anchors->ref();
......@@ -2783,6 +2776,7 @@ bool KHTMLPart::processObjectRequest( khtml::ChildFrame *child, const KURL &_url
KHTMLPart* p = static_cast<KHTMLPart*>(static_cast<KParts::ReadOnlyPart *>(child->m_part));
p->begin();
p->m_url = url;
p->write(url.path());
p->end();
return true;
......@@ -2855,7 +2849,7 @@ KParts::PartManager *KHTMLPart::partManager()
void KHTMLPart::submitFormAgain()
{
if( !d->m_bParsing && d->m_submitForm)
KHTMLPart::submitForm( d->m_submitForm->submitAction, d->m_submitForm->submitUrl, d->m_submitForm->submitFormData, d->m_submitForm->submitContentType, d->m_submitForm->submitBoundary );
KHTMLPart::submitForm( d->m_submitForm->submitAction, d->m_submitForm->submitUrl, d->m_submitForm->submitFormData, d->m_submitForm->target, d->m_submitForm->submitContentType, d->m_submitForm->submitBoundary );
delete d->m_submitForm;
d->m_submitForm = 0;
......@@ -2927,6 +2921,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
d->m_submitForm->submitAction = action;
d->m_submitForm->submitUrl = url;
d->m_submitForm->submitFormData = formData;
d->m_submitForm->target = _target;
d->m_submitForm->submitContentType = contentType;
d->m_submitForm->submitBoundary = boundary;
connect(this, SIGNAL(completed()), this, SLOT(submitFormAgain()));
......@@ -3265,7 +3260,7 @@ void KHTMLPart::restoreState( QDataStream &stream )
Q_INT32 charset;
long old_cacheId = d->m_cacheId;
QString encoding;
stream >> u >> xOffset >> yOffset;
// restore link cursor position
......@@ -3281,8 +3276,8 @@ void KHTMLPart::restoreState( QDataStream &stream )
d->m_encoding = encoding;
if ( d->m_settings ) d->m_settings->setCharset( d->m_charset );
kdDebug(6050)<<"restoring charset to:"<< charset << endl;
stream >> fSizes >> d->m_fontBase;
// ### odd: this doesn't appear to have any influence on the used font
// sizes :(
......
......@@ -123,14 +123,14 @@ void KHTMLSettings::init( KConfig * config, bool reset )
defaultFonts.append( QString( "0" ) ); // font size adjustment
}
if ( reset || config->hasKey( "MinimumFontSize" ) )
m_minFontSize = config->readNumEntry( "MinimumFontSize", HTML_DEFAULT_MIN_FONT_SIZE );
if ( reset || config->hasKey( "MediumFontSize" ) ) {
m_fontSize = config->readNumEntry( "MediumFontSize", 10 );
resetFontSizes();
}
if ( reset || config->hasKey( "MinimumFontSize" ) )
m_minFontSize = config->readNumEntry( "MinimumFontSize", HTML_DEFAULT_MIN_FONT_SIZE );
QStringList chSets = KGlobal::charsets()->availableCharsetNames();
for ( QStringList::Iterator it = chSets.begin(); it != chSets.end(); ++it ) {
if ( reset || config->hasKey( *it ) ){
......