OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "platform/text/TextStream.h" | 27 #include "platform/text/TextStream.h" |
28 | 28 |
| 29 #include "platform/geometry/FloatPoint.h" |
| 30 #include "platform/geometry/FloatRect.h" |
| 31 #include "platform/geometry/FloatSize.h" |
| 32 #include "platform/geometry/IntPoint.h" |
| 33 #include "platform/geometry/IntRect.h" |
29 #include "wtf/MathExtras.h" | 34 #include "wtf/MathExtras.h" |
30 #include "wtf/StringExtras.h" | 35 #include "wtf/StringExtras.h" |
31 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
32 | 37 |
33 using namespace std; | 38 using namespace std; |
34 | 39 |
35 namespace WebCore { | 40 namespace WebCore { |
36 | 41 |
37 static const size_t printBufferSize = 100; // large enough for any integer or fl
oating point value in string format, including trailing null character | 42 static const size_t printBufferSize = 100; // large enough for any integer or fl
oating point value in string format, including trailing null character |
38 | 43 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return *this; | 130 return *this; |
126 } | 131 } |
127 | 132 |
128 String TextStream::release() | 133 String TextStream::release() |
129 { | 134 { |
130 String result = m_text.toString(); | 135 String result = m_text.toString(); |
131 m_text.clear(); | 136 m_text.clear(); |
132 return result; | 137 return result; |
133 } | 138 } |
134 | 139 |
| 140 TextStream& operator<<(TextStream& ts, const IntRect& r) |
| 141 { |
| 142 return ts << "at (" << r.x() << "," << r.y() << ") size " << r.width() << "x
" << r.height(); |
135 } | 143 } |
| 144 |
| 145 TextStream& operator<<(TextStream& ts, const IntPoint& p) |
| 146 { |
| 147 return ts << "(" << p.x() << "," << p.y() << ")"; |
| 148 } |
| 149 |
| 150 TextStream& operator<<(TextStream& ts, const FloatPoint& p) |
| 151 { |
| 152 ts << "(" << TextStream::FormatNumberRespectingIntegers(p.x()); |
| 153 ts << "," << TextStream::FormatNumberRespectingIntegers(p.y()); |
| 154 ts << ")"; |
| 155 return ts; |
| 156 } |
| 157 |
| 158 TextStream& operator<<(TextStream& ts, const FloatSize& s) |
| 159 { |
| 160 ts << "width=" << TextStream::FormatNumberRespectingIntegers(s.width()); |
| 161 ts << " height=" << TextStream::FormatNumberRespectingIntegers(s.height()); |
| 162 return ts; |
| 163 } |
| 164 |
| 165 TextStream& operator<<(TextStream& ts, const FloatRect& r) |
| 166 { |
| 167 ts << "at (" << TextStream::FormatNumberRespectingIntegers(r.x()); |
| 168 ts << "," << TextStream::FormatNumberRespectingIntegers(r.y()); |
| 169 ts << ") size " << TextStream::FormatNumberRespectingIntegers(r.width()); |
| 170 ts << "x" << TextStream::FormatNumberRespectingIntegers(r.height()); |
| 171 return ts; |
| 172 } |
| 173 |
| 174 void writeIndent(TextStream& ts, int indent) |
| 175 { |
| 176 for (int i = 0; i != indent; ++i) |
| 177 ts << " "; |
| 178 } |
| 179 |
| 180 } |
OLD | NEW |