OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/css/CSSQuadValue.h" |
| 7 |
| 8 #include "wtf/text/StringBuilder.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 String CSSQuadValue::generateCSSString(const String& top, const String& right, c
onst String& bottom, const String& left, bool serializeAsRect) |
| 13 { |
| 14 if (serializeAsRect) |
| 15 return "rect(" + top + ' ' + right + ' ' + bottom + ' ' + left + ')'; |
| 16 |
| 17 StringBuilder result; |
| 18 // reserve space for the four strings, plus three space separator characters
. |
| 19 result.reserveCapacity(top.length() + right.length() + bottom.length() + lef
t.length() + 3); |
| 20 result.append(top); |
| 21 if (right != top || bottom != top || left != top) { |
| 22 result.append(' '); |
| 23 result.append(right); |
| 24 if (bottom != top || right != left) { |
| 25 result.append(' '); |
| 26 result.append(bottom); |
| 27 if (left != right) { |
| 28 result.append(' '); |
| 29 result.append(left); |
| 30 } |
| 31 } |
| 32 } |
| 33 return result.toString(); |
| 34 } |
| 35 |
| 36 DEFINE_TRACE_AFTER_DISPATCH(CSSQuadValue) |
| 37 { |
| 38 visitor->trace(m_top); |
| 39 visitor->trace(m_right); |
| 40 visitor->trace(m_bottom); |
| 41 visitor->trace(m_left); |
| 42 CSSValue::traceAfterDispatch(visitor); |
| 43 } |
| 44 |
| 45 } |
OLD | NEW |