KHtml

csshelper.cpp
1 /*
2  * This file is part of the CSS implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 #include "csshelper.h"
23 
24 #include "misc/helper.h"
25 #include "xml/dom_stringimpl.h"
26 
27 using namespace DOM;
28 using namespace khtml;
29 
30 DOMString khtml::parseURL(const DOMString &url)
31 {
32  DOMStringImpl *i = url.implementation();
33  if (!i) {
34  return DOMString();
35  }
36 
37  int o = 0;
38  int l = i->l;
39  while (o < l && (i->s[o] <= ' ')) {
40  o++;
41  l--;
42  }
43  while (l > 0 && (i->s[o + l - 1] <= ' ')) {
44  l--;
45  }
46 
47  if (l >= 5 &&
48  (i->s[o].toLower() == 'u') &&
49  (i->s[o + 1].toLower() == 'r') &&
50  (i->s[o + 2].toLower() == 'l') &&
51  i->s[o + 3].toLatin1() == '(' &&
52  i->s[o + l - 1].toLatin1() == ')') {
53  o += 4;
54  l -= 5;
55  }
56 
57  while (o < l && (i->s[o] <= ' ')) {
58  o++;
59  l--;
60  }
61  while (l > 0 && (i->s[o + l - 1] <= ' ')) {
62  l--;
63  }
64 
65  if (l >= 2 && i->s[o] == i->s[o + l - 1] &&
66  (i->s[o].toLatin1() == '\'' || i->s[o].toLatin1() == '\"')) {
67  o++;
68  l -= 2;
69  }
70 
71  while (o < l && (i->s[o] <= ' ')) {
72  o++;
73  l--;
74  }
75  while (l > 0 && (i->s[o + l - 1] <= ' ')) {
76  l--;
77  }
78 
79  DOMStringImpl *j = new DOMStringImpl(i->s + o, l);
80 
81  int nl = 0;
82  for (int k = o; k < o + l; k++)
83  if (i->s[k].unicode() > '\r') {
84  j->s[nl++] = i->s[k];
85  }
86 
87  j->l = nl;
88 
89  return j;
90 }
This file is part of the HTML rendering engine for KDE.
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This library provides a full-featured HTML parser and widget.
DOMStringImpl * implementation() const
Definition: dom_string.h:145
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.