[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/khtml/css
From: Harri Porten <porten () kde ! org>
Date: 2008-11-29 9:14:19
Message-ID: 1227950059.928982.5712.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 890405 by porten:
Fixed excessive quoting of css values. Had integrated a WebCore
patch in 3.5-times when it was still incomplete it seems.
Todo: font-family should have different rules, double values
like borderspacing should not be treated like strings at all.
M +33 -2 css_valueimpl.cpp
--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #890404:890405
@@ -40,6 +40,8 @@
#include <rendering/font.h>
#include <rendering/render_style.h>
+#include <wtf/ASCIICType.h>
+
#include <kdebug.h>
#include <QtCore/QRegExp>
#include <QtGui/QPaintDevice>
@@ -50,6 +52,7 @@
using khtml::FontDef;
using namespace DOM;
+using namespace WTF;
static int propertyID(const DOMString &s)
{
@@ -69,9 +72,32 @@
return getPropertyID(buffer, len);
}
-// Quotes the string if it needs quoting.
-static DOMString quoteStringIfNeeded(const DOMString &string)
+// "ident" from the CSS tokenizer, minus backslash-escape sequences
+static bool isCSSTokenizerIdentifier(const DOMString& string)
{
+ const QChar* p = string.unicode();
+ const QChar* end = p + string.length();
+
+ // -?
+ if (p != end && p[0] == '-')
+ ++p;
+
+ // {nmstart}
+ if (p == end || !(p[0] == '_' || p[0] >= 128 || isASCIIAlpha(p->unicode())))
+ return false;
+ ++p;
+
+ // {nmchar}*
+ for (; p != end; ++p) {
+ if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isASCIIAlphanumeric(p->unicode())))
+ return false;
+ }
+
+ return true;
+}
+
+static DOMString quoteString(const DOMString &string)
+{
// FIXME: Also need to transform control characters into \ sequences.
QString s = string.string();
s.replace('\\', "\\\\");
@@ -79,6 +105,11 @@
return '\'' + s + '\'';
}
+// Quotes the string if it needs quoting.
+static DOMString quoteStringIfNeeded(const DOMString &string)
+{
+ return isCSSTokenizerIdentifier(string) ? string : quoteString(string);
+}
CSSStyleDeclarationImpl::CSSStyleDeclarationImpl(CSSRuleImpl *parent)
: StyleBaseImpl(parent)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic