|
Lines 29-34
Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec1
|
| 29 |
#include <wtf/MathExtras.h> |
29 |
#include <wtf/MathExtras.h> |
| 30 |
#include <wtf/dtoa.h> |
30 |
#include <wtf/dtoa.h> |
| 31 |
#include <wtf/text/AtomicString.h> |
31 |
#include <wtf/text/AtomicString.h> |
|
|
32 |
#include <wtf/text/StringBuffer.h> |
| 32 |
|
33 |
|
| 33 |
namespace WebCore { |
34 |
namespace WebCore { |
| 34 |
|
35 |
|
|
Lines 57-62
String stripLeadingAndTrailingHTMLSpaces
Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec2
|
| 57 |
return string.substring(numLeadingSpaces, length - (numLeadingSpaces + numTrailingSpaces)); |
58 |
return string.substring(numLeadingSpaces, length - (numLeadingSpaces + numTrailingSpaces)); |
| 58 |
} |
59 |
} |
| 59 |
|
60 |
|
|
|
61 |
String simplifyHTMLWhiteSpace(const String& string) |
| 62 |
{ |
| 63 |
unsigned length = string.length(); |
| 64 |
const UChar* from = string.characters(); |
| 65 |
const UChar* fromend = from + length; |
| 66 |
int outc = 0; |
| 67 |
bool changedToSpace = false; |
| 68 |
|
| 69 |
StringBuffer data(length); |
| 70 |
UChar* to = data.characters(); |
| 71 |
|
| 72 |
while (true) { |
| 73 |
while (from != fromend && isHTMLSpace(*from)) { |
| 74 |
if (*from != ' ') |
| 75 |
changedToSpace = true; |
| 76 |
from++; |
| 77 |
} |
| 78 |
while (from != fromend && !isHTMLSpace(*from)) |
| 79 |
to[outc++] = *from++; |
| 80 |
if (from != fromend) |
| 81 |
to[outc++] = ' '; |
| 82 |
else |
| 83 |
break; |
| 84 |
} |
| 85 |
|
| 86 |
if (outc > 0 && to[outc - 1] == ' ') |
| 87 |
outc--; |
| 88 |
|
| 89 |
if (static_cast<unsigned>(outc) == length && !changedToSpace) |
| 90 |
return string; |
| 91 |
|
| 92 |
data.shrink(outc); |
| 93 |
|
| 94 |
return String::adopt(data); |
| 95 |
} |
| 96 |
|
| 60 |
String serializeForNumberType(double number) |
97 |
String serializeForNumberType(double number) |
| 61 |
{ |
98 |
{ |
| 62 |
// According to HTML5, "the best representation of the number n as a floating |
99 |
// According to HTML5, "the best representation of the number n as a floating |