| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Computer, 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 "core/css/CSSTimingFunctionValue.h" | 26 #include "core/css/CSSTimingFunctionValue.h" |
| 27 | 27 |
| 28 #include "core/css/serializer/CSSDeserializeStream.h" |
| 29 #include "core/css/serializer/CSSSerializeStream.h" |
| 28 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 29 | 31 |
| 30 namespace blink { | 32 namespace blink { |
| 31 | 33 |
| 34 PassRefPtrWillBeRawPtr<CSSCubicBezierTimingFunctionValue> CSSCubicBezierTimingFu
nctionValue::deserializeAfterDispatch(CSSDeserializeStream* stream) |
| 35 { |
| 36 double x1 = stream->readDouble(); |
| 37 double y1 = stream->readDouble(); |
| 38 double x2 = stream->readDouble(); |
| 39 double y2 = stream->readDouble(); |
| 40 return create(x1, y1, x2, y2); |
| 41 } |
| 42 |
| 32 String CSSCubicBezierTimingFunctionValue::customCSSText() const | 43 String CSSCubicBezierTimingFunctionValue::customCSSText() const |
| 33 { | 44 { |
| 34 return "cubic-bezier(" | 45 return "cubic-bezier(" |
| 35 + String::number(m_x1) + ", " | 46 + String::number(m_x1) + ", " |
| 36 + String::number(m_y1) + ", " | 47 + String::number(m_y1) + ", " |
| 37 + String::number(m_x2) + ", " | 48 + String::number(m_x2) + ", " |
| 38 + String::number(m_y2) + ")"; | 49 + String::number(m_y2) + ")"; |
| 39 } | 50 } |
| 40 | 51 |
| 41 bool CSSCubicBezierTimingFunctionValue::equals(const CSSCubicBezierTimingFunctio
nValue& other) const | 52 bool CSSCubicBezierTimingFunctionValue::equals(const CSSCubicBezierTimingFunctio
nValue& other) const |
| 42 { | 53 { |
| 43 return m_x1 == other.m_x1 && m_x2 == other.m_x2 && m_y1 == other.m_y1 && m_y
2 == other.m_y2; | 54 return m_x1 == other.m_x1 && m_x2 == other.m_x2 && m_y1 == other.m_y1 && m_y
2 == other.m_y2; |
| 44 } | 55 } |
| 45 | 56 |
| 57 void CSSCubicBezierTimingFunctionValue::serializeAfterDispatch(CSSSerializeStrea
m* stream) const |
| 58 { |
| 59 stream->writeDouble(m_x1); |
| 60 stream->writeDouble(m_y1); |
| 61 stream->writeDouble(m_x2); |
| 62 stream->writeDouble(m_y2); |
| 63 } |
| 64 |
| 65 PassRefPtrWillBeRawPtr<CSSStepsTimingFunctionValue> CSSStepsTimingFunctionValue:
:deserializeAfterDispatch(CSSDeserializeStream* stream) |
| 66 { |
| 67 int steps = stream->readInt(); |
| 68 StepsTimingFunction::StepAtPosition stepAtPosition = stream->readIntAsEnum<S
tepsTimingFunction::StepAtPosition>(); |
| 69 |
| 70 return create(steps, stepAtPosition); |
| 71 } |
| 72 |
| 46 String CSSStepsTimingFunctionValue::customCSSText() const | 73 String CSSStepsTimingFunctionValue::customCSSText() const |
| 47 { | 74 { |
| 48 String stepAtPositionString; | 75 String stepAtPositionString; |
| 49 switch (m_stepAtPosition) { | 76 switch (m_stepAtPosition) { |
| 50 case StepsTimingFunction::Start: | 77 case StepsTimingFunction::Start: |
| 51 stepAtPositionString = "start"; | 78 stepAtPositionString = "start"; |
| 52 break; | 79 break; |
| 53 case StepsTimingFunction::Middle: | 80 case StepsTimingFunction::Middle: |
| 54 stepAtPositionString = "middle"; | 81 stepAtPositionString = "middle"; |
| 55 break; | 82 break; |
| 56 case StepsTimingFunction::End: | 83 case StepsTimingFunction::End: |
| 57 stepAtPositionString = "end"; | 84 stepAtPositionString = "end"; |
| 58 break; | 85 break; |
| 59 default: | 86 default: |
| 60 ASSERT_NOT_REACHED(); | 87 ASSERT_NOT_REACHED(); |
| 61 stepAtPositionString = "end"; | 88 stepAtPositionString = "end"; |
| 62 break; | 89 break; |
| 63 } | 90 } |
| 64 return "steps(" + String::number(m_steps) + ", " + stepAtPositionString + ')
'; | 91 return "steps(" + String::number(m_steps) + ", " + stepAtPositionString + ')
'; |
| 65 } | 92 } |
| 66 | 93 |
| 67 bool CSSStepsTimingFunctionValue::equals(const CSSStepsTimingFunctionValue& othe
r) const | 94 bool CSSStepsTimingFunctionValue::equals(const CSSStepsTimingFunctionValue& othe
r) const |
| 68 { | 95 { |
| 69 return m_steps == other.m_steps && m_stepAtPosition == other.m_stepAtPositio
n; | 96 return m_steps == other.m_steps && m_stepAtPosition == other.m_stepAtPositio
n; |
| 70 } | 97 } |
| 71 | 98 |
| 99 void CSSStepsTimingFunctionValue::serializeAfterDispatch(CSSSerializeStream* str
eam) const |
| 100 { |
| 101 stream->writeInt(m_steps); |
| 102 stream->writeEnumAsInt<StepsTimingFunction::StepAtPosition>(m_stepAtPosition
); |
| 103 } |
| 104 |
| 72 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |