Commit 570425a3 authored by Andrea Iacovitti's avatar Andrea Iacovitti

Introduce DOMString::trimSpaces(), useful for removing space characters from url string.

parent 9ba9651c
...@@ -1383,9 +1383,9 @@ CSSImageValueImpl::CSSImageValueImpl(const DOMString &url, StyleBaseImpl* style) ...@@ -1383,9 +1383,9 @@ CSSImageValueImpl::CSSImageValueImpl(const DOMString &url, StyleBaseImpl* style)
: CSSPrimitiveValueImpl(url, CSSPrimitiveValue::CSS_URI) : CSSPrimitiveValueImpl(url, CSSPrimitiveValue::CSS_URI)
{ {
m_image = 0; m_image = 0;
const QString imgUrl = url.string().trimmed(); const DOMString imgUrl = url.trimSpaces();
if (!imgUrl.isEmpty()) { if (!imgUrl.isEmpty()) {
m_fullImageUrl = KUrl(style->baseURL(), imgUrl).url(); m_fullImageUrl = KUrl(style->baseURL(), imgUrl.string()).url();
} else { } else {
m_fullImageUrl.clear(); m_fullImageUrl.clear();
} }
......
...@@ -2309,8 +2309,8 @@ bool CSSParser::parseFontFaceSrc() ...@@ -2309,8 +2309,8 @@ bool CSSParser::parseFontFaceSrc()
while ((val = valueList->current())) { while ((val = valueList->current())) {
CSSFontFaceSrcValueImpl* parsedValue = 0; CSSFontFaceSrcValueImpl* parsedValue = 0;
if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma && styleElement) { if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma && styleElement) {
const QString uri = qString(val->string).trimmed(); const DOMString uri = domString(val->string).trimSpaces();
parsedValue = new CSSFontFaceSrcValueImpl(DOMString(KUrl(styleElement->baseURL(), uri).url()), false /*local*/); parsedValue = new CSSFontFaceSrcValueImpl(DOMString(KUrl(styleElement->baseURL(), uri.string()).url()), false /*local*/);
uriValue = parsedValue; uriValue = parsedValue;
allowFormat = true; allowFormat = true;
expectComma = true; expectComma = true;
......
...@@ -290,6 +290,38 @@ bool DOMString::startsWith(const DOMString& str) const ...@@ -290,6 +290,38 @@ bool DOMString::startsWith(const DOMString& str) const
return impl->startsWith(str.implementation()); return impl->startsWith(str.implementation());
} }
static inline bool isSpaceCharacter(const ushort &c)
{
// http://dev.w3.org/html5/spec-LC/common-microsyntaxes.html#space-character
return ((c < 0x0021) &&
(c == 0x0020 || c == 0x0009 || c == 0x000A || c == 0x000C || c == 0x000D));
}
DOMString DOMString::trimSpaces() const
{
if (!impl || !impl->l) {
return *this;
}
const QChar *s = impl->s;
unsigned int start = 0;
unsigned int end = impl->l - 1;
while ((start <= end) && isSpaceCharacter(s[start].unicode())) {
++start;
}
if (start > end) {
return DOMString("");
}
while (end && isSpaceCharacter(s[end].unicode())) {
--end;
}
return new DOMStringImpl(s + start, end - start + 1);
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
bool DOM::strcasecmp( const DOMString &as, const DOMString &bs ) bool DOM::strcasecmp( const DOMString &as, const DOMString &bs )
......
...@@ -124,6 +124,13 @@ public: ...@@ -124,6 +124,13 @@ public:
bool endsWith(const DOMString& str) const; bool endsWith(const DOMString& str) const;
bool startsWith(const DOMString& str) const; bool startsWith(const DOMString& str) const;
/**
* Returns a string with Space Characters removed from the start and the end.
* Space Characters as defined in
* http://dev.w3.org/html5/spec-LC/common-microsyntaxes.html#space-character
*/
DOMString trimSpaces() const;
/** /**
* @internal get a handle to the imlementation of the DOMString * @internal get a handle to the imlementation of the DOMString
* Use at own risk!!! * Use at own risk!!!
......
...@@ -231,8 +231,8 @@ void HTMLFrameElement::setScrolling( const DOMString &value ) ...@@ -231,8 +231,8 @@ void HTMLFrameElement::setScrolling( const DOMString &value )
DOMString HTMLFrameElement::src() const DOMString HTMLFrameElement::src() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).string().trimmed(); const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces();
return !s.isNull() ? impl->document()->completeURL(s) : DOMString(); return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
} }
void HTMLFrameElement::setSrc( const DOMString &value ) void HTMLFrameElement::setSrc( const DOMString &value )
...@@ -367,8 +367,8 @@ void HTMLIFrameElement::setScrolling( const DOMString &value ) ...@@ -367,8 +367,8 @@ void HTMLIFrameElement::setScrolling( const DOMString &value )
DOMString HTMLIFrameElement::src() const DOMString HTMLIFrameElement::src() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).string().trimmed(); const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces();
return !s.isNull() ? impl->document()->completeURL(s) : DOMString(); return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
} }
void HTMLIFrameElement::setSrc( const DOMString &value ) void HTMLIFrameElement::setSrc( const DOMString &value )
......
...@@ -100,7 +100,7 @@ DOMString HTMLDocument::referrer() const ...@@ -100,7 +100,7 @@ DOMString HTMLDocument::referrer() const
DOMString HTMLDocument::completeURL(const DOMString& str) const DOMString HTMLDocument::completeURL(const DOMString& str) const
{ {
if(!impl) return str; if(!impl) return str;
return ((HTMLDocumentImpl *)impl)->completeURL(str.string().trimmed()); return ((HTMLDocumentImpl *)impl)->completeURL(str.trimSpaces().string());
} }
DOMString HTMLDocument::domain() const DOMString HTMLDocument::domain() const
......
...@@ -504,8 +504,8 @@ void HTMLInputElement::setSize( long value ) ...@@ -504,8 +504,8 @@ void HTMLInputElement::setSize( long value )
DOMString HTMLInputElement::src() const DOMString HTMLInputElement::src() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString s = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_SRC).string().trimmed(); const DOMString s = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_SRC).trimSpaces();
return !s.isNull() ? impl->document()->completeURL(s) : DOMString(); return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
} }
void HTMLInputElement::setSrc( const DOMString &value ) void HTMLInputElement::setSrc( const DOMString &value )
......
...@@ -58,8 +58,8 @@ HTMLBaseElement::~HTMLBaseElement() ...@@ -58,8 +58,8 @@ HTMLBaseElement::~HTMLBaseElement()
DOMString HTMLBaseElement::href() const DOMString HTMLBaseElement::href() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).string().trimmed(); const DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).trimSpaces();
return !href.isNull() ? impl->document()->completeURL(href) : DOMString(); return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
} }
void HTMLBaseElement::setHref( const DOMString &value ) void HTMLBaseElement::setHref( const DOMString &value )
...@@ -134,8 +134,8 @@ void HTMLLinkElement::setCharset( const DOMString &value ) ...@@ -134,8 +134,8 @@ void HTMLLinkElement::setCharset( const DOMString &value )
DOMString HTMLLinkElement::href() const DOMString HTMLLinkElement::href() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).string().trimmed(); const DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).trimSpaces();
return !href.isNull() ? impl->document()->completeURL(href) : DOMString(); return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
} }
void HTMLLinkElement::setHref( const DOMString &value ) void HTMLLinkElement::setHref( const DOMString &value )
...@@ -379,8 +379,8 @@ void HTMLScriptElement::setDefer( bool _defer ) ...@@ -379,8 +379,8 @@ void HTMLScriptElement::setDefer( bool _defer )
DOMString HTMLScriptElement::src() const DOMString HTMLScriptElement::src() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).string().trimmed(); const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces();
return !s.isNull() ? impl->document()->completeURL(s) : DOMString(); return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
} }
void HTMLScriptElement::setSrc( const DOMString &value ) void HTMLScriptElement::setSrc( const DOMString &value )
......
...@@ -95,8 +95,8 @@ void HTMLAreaElement::setCoords( const DOMString &value ) ...@@ -95,8 +95,8 @@ void HTMLAreaElement::setCoords( const DOMString &value )
DOMString HTMLAreaElement::href() const DOMString HTMLAreaElement::href() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).string().trimmed(); const DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).trimSpaces();
return !href.isNull() ? impl->document()->completeURL(href) : DOMString(); return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
} }
void HTMLAreaElement::setHref( const DOMString &value ) void HTMLAreaElement::setHref( const DOMString &value )
...@@ -302,8 +302,8 @@ void HTMLImageElement::setLongDesc( const DOMString &value ) ...@@ -302,8 +302,8 @@ void HTMLImageElement::setLongDesc( const DOMString &value )
DOMString HTMLImageElement::src() const DOMString HTMLImageElement::src() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).string().trimmed(); const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces();
return !s.isNull() ? impl->document()->completeURL(s) : DOMString(); return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
} }
void HTMLImageElement::setSrc( const DOMString &value ) void HTMLImageElement::setSrc( const DOMString &value )
......
...@@ -95,8 +95,8 @@ void HTMLAnchorElement::setCoords( const DOMString &value ) ...@@ -95,8 +95,8 @@ void HTMLAnchorElement::setCoords( const DOMString &value )
DOMString HTMLAnchorElement::href() const DOMString HTMLAnchorElement::href() const
{ {
if(!impl) return DOMString(); if(!impl) return DOMString();
const QString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).string().trimmed(); const DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF).trimSpaces();
return !href.isNull() ? impl->document()->completeURL(href) : DOMString(); return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
} }
void HTMLAnchorElement::setHref( const DOMString &value ) void HTMLAnchorElement::setHref( const DOMString &value )
......
...@@ -1587,8 +1587,8 @@ QHash<int, const HTMLElement::BoundPropInfo*>* HTMLElement::boundPropInfo() ...@@ -1587,8 +1587,8 @@ QHash<int, const HTMLElement::BoundPropInfo*>* HTMLElement::boundPropInfo()
QString KJS::HTMLElement::getURLArg(unsigned id) const QString KJS::HTMLElement::getURLArg(unsigned id) const
{ {
const QString rel = impl()->getAttribute(id).string().trimmed(); const DOMString rel = impl()->getAttribute(id).trimSpaces();
return !rel.isNull() ? impl()->document()->completeURL(rel) : rel; return !rel.isNull() ? impl()->document()->completeURL(rel.string()) : QString();
} }
DOM::HTMLElementImpl *toHTMLElement(JSValue *val) { DOM::HTMLElementImpl *toHTMLElement(JSValue *val) {
......
...@@ -906,7 +906,8 @@ JSValue *XMLHttpRequestProtoFunc::callAsFunction(ExecState *exec, JSObject *this ...@@ -906,7 +906,8 @@ JSValue *XMLHttpRequestProtoFunc::callAsFunction(ExecState *exec, JSObject *this
return throwError(exec, SyntaxError, "Not enough arguments"); return throwError(exec, SyntaxError, "Not enough arguments");
QString method = args[0]->toString(exec).qstring(); QString method = args[0]->toString(exec).qstring();
KUrl url = KUrl(request->doc->completeURL(args[1]->toString(exec).qstring())); DOMString urlArg = args[1]->toString(exec).domString().trimSpaces();
KUrl url = KUrl(request->doc->completeURL(urlArg.string()));
bool async = true; bool async = true;
if (args.size() >= 3) { if (args.size() >= 3) {
......
...@@ -71,7 +71,7 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -71,7 +71,7 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
case ATTR_BACKGROUND: case ATTR_BACKGROUND:
{ {
QString url = attr->val()->string().trimmed(); QString url = attr->value().trimSpaces().string();
if (!url.isEmpty()) { if (!url.isEmpty()) {
url = document()->completeURL( url ); url = document()->completeURL( url );
addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") ); addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") );
...@@ -325,7 +325,7 @@ void HTMLFrameElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -325,7 +325,7 @@ void HTMLFrameElementImpl::parseAttribute(AttributeImpl *attr)
switch(attr->id()) switch(attr->id())
{ {
case ATTR_SRC: case ATTR_SRC:
setLocation(attr->value().string().trimmed()); setLocation(attr->value().trimSpaces().string());
break; break;
case ATTR_FRAMEBORDER: case ATTR_FRAMEBORDER:
{ {
...@@ -755,7 +755,7 @@ void HTMLIFrameElementImpl::parseAttribute(AttributeImpl *attr ) ...@@ -755,7 +755,7 @@ void HTMLIFrameElementImpl::parseAttribute(AttributeImpl *attr )
addHTMLAlignment( attr->value() ); addHTMLAlignment( attr->value() );
break; break;
case ATTR_SRC: case ATTR_SRC:
url = attr->value().string().trimmed(); url = attr->value().trimSpaces().string();
setNeedComputeContent(); setNeedComputeContent();
// ### synchronously start the process? // ### synchronously start the process?
break; break;
......
...@@ -679,7 +679,7 @@ void HTMLFormElementImpl::submit( ) ...@@ -679,7 +679,7 @@ void HTMLFormElementImpl::submit( )
} }
#endif // KHTML_NO_WALLET #endif // KHTML_NO_WALLET
QString url = getAttribute(ATTR_ACTION).string().trimmed(); QString url = getAttribute(ATTR_ACTION).trimSpaces().string();
// ignore base url if 'action' attribute is empty. // ignore base url if 'action' attribute is empty.
if (url.isEmpty()) if (url.isEmpty())
url = formUrl.url(); url = formUrl.url();
......
...@@ -55,7 +55,7 @@ void HTMLBaseElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -55,7 +55,7 @@ void HTMLBaseElementImpl::parseAttribute(AttributeImpl *attr)
switch(attr->id()) switch(attr->id())
{ {
case ATTR_HREF: case ATTR_HREF:
m_href = attr->value().string().trimmed(); m_href = attr->value().trimSpaces().string();
process(); process();
break; break;
case ATTR_TARGET: case ATTR_TARGET:
...@@ -116,9 +116,9 @@ void HTMLLinkElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -116,9 +116,9 @@ void HTMLLinkElementImpl::parseAttribute(AttributeImpl *attr)
switch (attr->id()) switch (attr->id())
{ {
case ATTR_HREF: { case ATTR_HREF: {
const QString hrefUrl = attr->val()->string().trimmed(); const DOMString hrefUrl = attr->value().trimSpaces();
if (!hrefUrl.isEmpty()) { if (!hrefUrl.isEmpty()) {
m_url = document()->completeURL(hrefUrl); m_url = document()->completeURL(hrefUrl.string());
} }
process(); process();
break; break;
...@@ -385,7 +385,7 @@ void HTMLScriptElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -385,7 +385,7 @@ void HTMLScriptElementImpl::parseAttribute(AttributeImpl *attr)
// we'll only start doing things once we get insertedIntoDocument() // we'll only start doing things once we get insertedIntoDocument()
if (m_evaluated || m_cachedScript || m_createdByParser || !inDocument()) if (m_evaluated || m_cachedScript || m_createdByParser || !inDocument())
return; return;
QString url = attr->value().string().trimmed(); const DOMString url = attr->value().trimSpaces();
if (!url.isEmpty()) if (!url.isEmpty())
loadFromUrl(url); loadFromUrl(url);
break; break;
...@@ -490,7 +490,7 @@ void HTMLScriptElementImpl::insertedIntoDocument() ...@@ -490,7 +490,7 @@ void HTMLScriptElementImpl::insertedIntoDocument()
if (m_createdByParser) if (m_createdByParser)
return; return;
QString url = getAttribute(ATTR_SRC).string().trimmed(); const DOMString url = getAttribute(ATTR_SRC).trimSpaces();
if (!url.isEmpty()) { if (!url.isEmpty()) {
loadFromUrl(url); loadFromUrl(url);
return; return;
...@@ -622,7 +622,7 @@ void HTMLScriptElementImpl::setDefer(bool defer) ...@@ -622,7 +622,7 @@ void HTMLScriptElementImpl::setDefer(bool defer)
DOMString HTMLScriptElementImpl::src() const DOMString HTMLScriptElementImpl::src() const
{ {
return document()->completeURL(getAttribute(ATTR_SRC).string().trimmed()); return document()->completeURL(getAttribute(ATTR_SRC).trimSpaces().string());
} }
void HTMLScriptElementImpl::setSrc(const DOMString &value) void HTMLScriptElementImpl::setSrc(const DOMString &value)
......
...@@ -84,7 +84,7 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -84,7 +84,7 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
setChanged(); setChanged();
//Start loading the image already, to generate events //Start loading the image already, to generate events
const QString imgSrcUrl = attr->value().string().trimmed(); const DOMString imgSrcUrl = attr->value().trimSpaces();
if (!imgSrcUrl.isEmpty()) { //### why do we not hide or something when setting this? if (!imgSrcUrl.isEmpty()) { //### why do we not hide or something when setting this?
CachedImage* newImage = document()->docLoader()->requestImage(imgSrcUrl); CachedImage* newImage = document()->docLoader()->requestImage(imgSrcUrl);
if (newImage && newImage != m_image) { if (newImage && newImage != m_image) {
...@@ -151,7 +151,7 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -151,7 +151,7 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
if ( attr->value()[0] == '#' ) if ( attr->value()[0] == '#' )
usemap = attr->value().lower(); usemap = attr->value().lower();
else { else {
QString url = document()->completeURL(attr->value().string().trimmed()); QString url = document()->completeURL(attr->value().trimSpaces().string());
// ### we remove the part before the anchor and hope // ### we remove the part before the anchor and hope
// the map is on the same html page.... // the map is on the same html page....
usemap = url; usemap = url;
...@@ -438,7 +438,7 @@ void HTMLMapElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -438,7 +438,7 @@ void HTMLMapElementImpl::parseAttribute(AttributeImpl *attr)
} }
else { else {
// add name with full url: // add name with full url:
const QString url = document()->completeURL(attr->value().string().trimmed()); const QString url = document()->completeURL(attr->value().trimSpaces().string());
if(document()->isHTMLDocument()) if(document()->isHTMLDocument())
static_cast<HTMLDocumentImpl*>(document())->mapMap[url] = this; static_cast<HTMLDocumentImpl*>(document())->mapMap[url] = this;
} }
......
...@@ -81,7 +81,7 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt) ...@@ -81,7 +81,7 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt)
if (k->qKeyEvent()) k->qKeyEvent()->accept(); if (k->qKeyEvent()) k->qKeyEvent()->accept();
} }
QString url = getAttribute(ATTR_HREF).string().trimmed(); QString url = getAttribute(ATTR_HREF).trimSpaces().string();
QString utarget = getAttribute(ATTR_TARGET).string(); QString utarget = getAttribute(ATTR_TARGET).string();
if ( e && e->button() == 1 ) if ( e && e->button() == 1 )
......
...@@ -695,7 +695,7 @@ void HTMLEmbedElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -695,7 +695,7 @@ void HTMLEmbedElementImpl::parseAttribute(AttributeImpl *attr)
{ {
case ATTR_CODE: case ATTR_CODE:
case ATTR_SRC: case ATTR_SRC:
url = attr->val()->string().trimmed(); url = attr->value().trimSpaces().string();
setNeedComputeContent(); setNeedComputeContent();
break; break;
case ATTR_BORDER: case ATTR_BORDER:
...@@ -775,7 +775,7 @@ void HTMLObjectElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -775,7 +775,7 @@ void HTMLObjectElementImpl::parseAttribute(AttributeImpl *attr)
switch ( attr->id() ) switch ( attr->id() )
{ {
case ATTR_DATA: case ATTR_DATA:
url = attr->val()->string().trimmed(); url = attr->value().trimSpaces().string();
setNeedComputeContent(); setNeedComputeContent();
break; break;
case ATTR_CLASSID: case ATTR_CLASSID:
......
...@@ -495,7 +495,7 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -495,7 +495,7 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
break; break;
case ATTR_BACKGROUND: case ATTR_BACKGROUND:
{ {
QString url = attr->val()->string().trimmed(); QString url = attr->value().trimSpaces().string();
if (!url.isEmpty()) { if (!url.isEmpty()) {
url = document()->completeURL( url ); url = document()->completeURL( url );
addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") ); addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") );
...@@ -638,7 +638,7 @@ void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr) ...@@ -638,7 +638,7 @@ void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr)
break; break;
case ATTR_BACKGROUND: case ATTR_BACKGROUND:
{ {
QString url = attr->val()->string().trimmed(); QString url = attr->value().trimSpaces().string();
if (!url.isEmpty()) { if (!url.isEmpty()) {
url = document()->completeURL( url ); url = document()->completeURL( url );
addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") ); addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") );
......
...@@ -974,7 +974,7 @@ NodeImpl *KHTMLParser::getElement(Token* t) ...@@ -974,7 +974,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
KHTMLGlobal::defaultHTMLSettings()->isHideAdsEnabled() && KHTMLGlobal::defaultHTMLSettings()->isHideAdsEnabled() &&
!strcasecmp( t->attrs->getValue( ATTR_TYPE ), "image" ) ) !strcasecmp( t->attrs->getValue( ATTR_TYPE ), "image" ) )
{ {
const QString url = doc()->completeURL(t->attrs->getValue(ATTR_SRC)->string().trimmed()); const QString url = doc()->completeURL(DOMString(t->attrs->getValue(ATTR_SRC)).trimSpaces().string());
if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered(url)) if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered(url))
return 0; return 0;
} }
...@@ -1104,7 +1104,7 @@ NodeImpl *KHTMLParser::getElement(Token* t) ...@@ -1104,7 +1104,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
KHTMLGlobal::defaultHTMLSettings()->isAdFilterEnabled()&& KHTMLGlobal::defaultHTMLSettings()->isAdFilterEnabled()&&
KHTMLGlobal::defaultHTMLSettings()->isHideAdsEnabled()) KHTMLGlobal::defaultHTMLSettings()->isHideAdsEnabled())
{ {
const QString url = doc()->completeURL(t->attrs->getValue(ATTR_SRC)->string().trimmed()); const QString url = doc()->completeURL(DOMString(t->attrs->getValue(ATTR_SRC)).trimSpaces().string());
if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered(url)) if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered(url))
return 0; return 0;
} }
......
...@@ -706,7 +706,7 @@ void ProspectiveTokenizer::processAttribute() ...@@ -706,7 +706,7 @@ void ProspectiveTokenizer::processAttribute()
LocalName attrLocal = LocalName::fromString(&attrDS, IDS_NormalizeLower); LocalName attrLocal = LocalName::fromString(&attrDS, IDS_NormalizeLower);
uint attribute = attrLocal.id(); uint attribute = attrLocal.id();
if (attribute == localNamePart(ATTR_SRC) && m_urlToLoad.isEmpty()) if (attribute == localNamePart(ATTR_SRC) && m_urlToLoad.isEmpty())
m_urlToLoad = DOMString(QString(m_attributeValue.data(), m_attributeValue.size()).trimmed()); m_urlToLoad = DOMString(m_attributeValue.data(), m_attributeValue.size()).trimSpaces();
break; break;
} }
case ID_LINK: case ID_LINK:
...@@ -715,7 +715,7 @@ void ProspectiveTokenizer::processAttribute() ...@@ -715,7 +715,7 @@ void ProspectiveTokenizer::processAttribute()
LocalName attrLocal = LocalName::fromString(&attrDS, IDS_NormalizeLower); LocalName attrLocal = LocalName::fromString(&attrDS, IDS_NormalizeLower);
uint attribute = attrLocal.id(); uint attribute = attrLocal.id();
if (attribute == localNamePart(ATTR_HREF) && m_urlToLoad.isEmpty()) if (attribute == localNamePart(ATTR_HREF) && m_urlToLoad.isEmpty())
m_urlToLoad = DOMString(QString(m_attributeValue.data(), m_attributeValue.size()).trimmed()); m_urlToLoad = DOMString(m_attributeValue.data(), m_attributeValue.size()).trimSpaces();
else if (attribute == localNamePart(ATTR_REL)) { else if (attribute == localNamePart(ATTR_REL)) {
DOMStringImpl* lowerAttribute = DOMStringImpl(DOMStringImpl::ShallowCopy, m_attributeValue.data(), m_attributeValue.size()).lower(); DOMStringImpl* lowerAttribute = DOMStringImpl(DOMStringImpl::ShallowCopy, m_attributeValue.data(), m_attributeValue.size()).lower();
QString val = lowerAttribute->string(); QString val = lowerAttribute->string();
......
...@@ -6420,7 +6420,7 @@ bool KHTMLPart::handleMouseMoveEventDrag(khtml::MouseMoveEvent *event) ...@@ -6420,7 +6420,7 @@ bool KHTMLPart::handleMouseMoveEventDrag(khtml::MouseMoveEvent *event)
if (url.isEmpty() && innerNodeImpl && innerNodeImpl->id() == ID_IMG) if (url.isEmpty() && innerNodeImpl && innerNodeImpl->id() == ID_IMG)
{ {
img = static_cast<HTMLImageElementImpl *>(innerNodeImpl); img = static_cast<HTMLImageElementImpl *>(innerNodeImpl);
u = completeURL(img->getAttribute(ATTR_SRC).string().trimmed()); u = completeURL(img->getAttribute(ATTR_SRC).trimSpaces().string());
pix = KIconLoader::global()->loadIcon("image-x-generic", KIconLoader::Desktop); pix = KIconLoader::global()->loadIcon("image-x-generic", KIconLoader::Desktop);
} }
else else
...@@ -6719,7 +6719,7 @@ void KHTMLPart::runAdFilter() ...@@ -6719,7 +6719,7 @@ void KHTMLPart::runAdFilter()
node->id() == ID_IFRAME || node->id() == ID_IFRAME ||
(node->id() == ID_INPUT && static_cast<