/platform/external/webkit/WebCore/css/CSSHelper.cpp

https://github.com/aharish/totoro-gb-opensource-update2 · C++ · 87 lines · 53 code · 14 blank · 20 comment · 39 complexity · 839a76b80eddd318871c517cf39bc608 MD5 · raw file

  1. /*
  2. * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  3. * Copyright (C) 2006, 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., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. *
  20. */
  21. #include "config.h"
  22. #include "CSSHelper.h"
  23. #include "PlatformString.h"
  24. #include <wtf/Vector.h>
  25. namespace WebCore {
  26. String deprecatedParseURL(const String& url)
  27. {
  28. StringImpl* i = url.impl();
  29. if (!i)
  30. return String();
  31. int o = 0;
  32. int l = i->length();
  33. while (o < l && (*i)[o] <= ' ') {
  34. ++o;
  35. --l;
  36. }
  37. while (l > 0 && (*i)[o + l - 1] <= ' ')
  38. --l;
  39. if (l >= 5
  40. && ((*i)[o] == 'u' || (*i)[o] == 'U')
  41. && ((*i)[o + 1] == 'r' || (*i)[o + 1] == 'R')
  42. && ((*i)[o + 2] == 'l' || (*i)[o + 2] == 'L')
  43. && (*i)[o + 3] == '('
  44. && (*i)[o + l - 1] == ')') {
  45. o += 4;
  46. l -= 5;
  47. }
  48. while (o < l && (*i)[o] <= ' ') {
  49. ++o;
  50. --l;
  51. }
  52. while (l > 0 && (*i)[o + l - 1] <= ' ')
  53. --l;
  54. if (l >= 2 && (*i)[o] == (*i)[o + l - 1] && ((*i)[o] == '\'' || (*i)[o] == '\"')) {
  55. o++;
  56. l -= 2;
  57. }
  58. while (o < l && (*i)[o] <= ' ') {
  59. ++o;
  60. --l;
  61. }
  62. while (l > 0 && (*i)[o + l - 1] <= ' ')
  63. --l;
  64. Vector<UChar, 2048> buffer(l);
  65. int nl = 0;
  66. for (int k = o; k < o + l; k++) {
  67. UChar c = (*i)[k];
  68. if (c > '\r')
  69. buffer[nl++] = c;
  70. }
  71. return String(buffer.data(), nl);
  72. }
  73. } // namespace WebCore