1 /*
2  * Copyright (C) 2007 David Smith (catfish.man@gmail.com)
3  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #include "ClassNames.h"
22 
23 namespace DOM
24 {
25 
parseClassAttribute(const DOMString & classStr,bool inCompatMode)26 void ClassNames::parseClassAttribute(const DOMString &classStr, bool inCompatMode)
27 {
28     if (!m_nameVector) {
29         m_nameVector.set(new ClassNameVector);
30     } else {
31         m_nameVector->clear();
32     }
33 
34     if (classStr.isEmpty()) {
35         return;
36     }
37 
38     DOMString classAttr = inCompatMode ? classStr.lower() : classStr;
39 
40     const QChar *str = classAttr.unicode();
41     const int length = classAttr.length();
42     int start = 0;
43     while (true) {
44         while (start < length && isClassWhitespace(str[start])) {
45             ++start;
46         }
47         if (start >= length) {
48             break;
49         }
50         int end = start + 1;
51         while (end < length && !isClassWhitespace(str[end])) {
52             ++end;
53         }
54 
55         m_nameVector->append(AtomicString(str + start, end - start));
56 
57         start = end + 1;
58     }
59 }
60 
61 } // namespace DOM
62 
63