15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * disclaimer. 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * disclaimer in the documentation and/or other materials 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * provided with the distribution. 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SUCH DAMAGE. 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "config.h" 3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/css/CSSBasicShapes.h" 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 33d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/css/CSSValuePool.h" 3409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/css/Pair.h" 35d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/Length.h" 36e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/text/StringBuilder.h" 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)using namespace WTF; 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 40c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 42d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CSSBasicShape) 43d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 44aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdochstatic String buildCircleString(const String& radius, const String& centerX, const String& centerY, const String& box) 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char at[] = "at"; 4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char separator[] = " "; 4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) StringBuilder result; 4909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral("circle("); 5009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!radius.isNull()) 5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(radius); 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!centerX.isNull() || !centerY.isNull()) { 5409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!radius.isNull()) 5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(at); 5709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 5809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(centerX); 5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 6009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(centerY); 6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 629e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles) result.append(')'); 63aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch if (box.length()) { 6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 65aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch result.append(box); 6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 6709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return result.toString(); 685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 70d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)static String serializePositionOffset(const Pair& offset, const Pair& other) 71d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 72d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if ((offset.first()->getValueID() == CSSValueLeft && other.first()->getValueID() == CSSValueTop) 73d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) || (offset.first()->getValueID() == CSSValueTop && other.first()->getValueID() == CSSValueLeft)) 74d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return offset.second()->cssText(); 75d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return offset.cssText(); 76d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 77d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 78d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> buildSerializablePositionOffset(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> offset, CSSValueID defaultSide) 79d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 80d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) CSSValueID side = defaultSide; 8107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch RefPtrWillBeRawPtr<CSSPrimitiveValue> amount = nullptr; 82d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 83d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!offset) { 84d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) side = CSSValueCenter; 85d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } else if (offset->isValueID()) { 86d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) side = offset->getValueID(); 87d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } else if (Pair* pair = offset->getPairValue()) { 88d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) side = pair->first()->getValueID(); 89d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) amount = pair->second(); 90d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } else { 91d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) amount = offset; 92d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 93d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 94d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (side == CSSValueCenter) { 95d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) side = defaultSide; 96d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) amount = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAGE); 97d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } else if ((side == CSSValueRight || side == CSSValueBottom) 98d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) && amount->isPercentage()) { 99d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) side = defaultSide; 100d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) amount = cssValuePool().createValue(100 - amount->getFloatValue(), CSSPrimitiveValue::CSS_PERCENTAGE); 101d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } else if (amount->isLength() && !amount->getFloatValue()) { 102d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (side == CSSValueRight || side == CSSValueBottom) 103d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) amount = cssValuePool().createValue(100, CSSPrimitiveValue::CSS_PERCENTAGE); 104d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) else 105d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) amount = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENTAGE); 106d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) side = defaultSide; 107d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 108d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 109d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return cssValuePool().createValue(Pair::create(cssValuePool().createValue(side), amount.release(), Pair::KeepIdenticalValues)); 110d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 111d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 1125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)String CSSBasicShapeCircle::cssText() const 1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 114d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RefPtrWillBeRawPtr<CSSPrimitiveValue> normalizedCX = buildSerializablePositionOffset(m_centerX, CSSValueLeft); 115d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RefPtrWillBeRawPtr<CSSPrimitiveValue> normalizedCY = buildSerializablePositionOffset(m_centerY, CSSValueTop); 116d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 117f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) String radius; 118f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (m_radius && m_radius->getValueID() != CSSValueClosestSide) 119f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) radius = m_radius->cssText(); 120f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 121f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) return buildCircleString(radius, 122d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) serializePositionOffset(*normalizedCX->getPairValue(), *normalizedCY->getPairValue()), 123d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) serializePositionOffset(*normalizedCY->getPairValue(), *normalizedCX->getPairValue()), 124aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch m_referenceBox ? m_referenceBox->cssText() : String()); 1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 127926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)bool CSSBasicShapeCircle::equals(const CSSBasicShape& shape) const 128926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){ 1295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) if (shape.type() != CSSBasicShapeCircleType) 130926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return false; 131926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 132926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) const CSSBasicShapeCircle& other = static_cast<const CSSBasicShapeCircle&>(shape); 133926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return compareCSSValuePtr(m_centerX, other.m_centerX) 134926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) && compareCSSValuePtr(m_centerY, other.m_centerY) 13509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_radius, other.m_radius) 136aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch && compareCSSValuePtr(m_referenceBox, other.m_referenceBox); 137926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 138926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 139d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void CSSBasicShapeCircle::trace(Visitor* visitor) 140d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 141d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_centerX); 142d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_centerY); 143d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_radius); 144d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) CSSBasicShape::trace(visitor); 145d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 146d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 14709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static String buildEllipseString(const String& radiusX, const String& radiusY, const String& centerX, const String& centerY, const String& box) 14809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 14909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char at[] = "at"; 15009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char separator[] = " "; 15109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) StringBuilder result; 15209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral("ellipse("); 15309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bool needsSeparator = false; 15409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!radiusX.isNull()) { 15509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(radiusX); 15609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) needsSeparator = true; 15709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 15809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!radiusY.isNull()) { 15909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (needsSeparator) 16009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 16109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(radiusY); 16209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) needsSeparator = true; 16309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 16409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 16509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!centerX.isNull() || !centerY.isNull()) { 16609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (needsSeparator) 16709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 16809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(at); 16909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 17009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(centerX); 17109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 17209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(centerY); 17309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 1749e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles) result.append(')'); 17509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (box.length()) { 17609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 17709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(box); 17809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 17909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return result.toString(); 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)String CSSBasicShapeEllipse::cssText() const 1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 184d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RefPtrWillBeRawPtr<CSSPrimitiveValue> normalizedCX = buildSerializablePositionOffset(m_centerX, CSSValueLeft); 185d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RefPtrWillBeRawPtr<CSSPrimitiveValue> normalizedCY = buildSerializablePositionOffset(m_centerY, CSSValueTop); 186d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 187f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) String radiusX; 188f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) String radiusY; 189f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (m_radiusX) { 190f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) bool shouldSerializeRadiusXValue = m_radiusX->getValueID() != CSSValueClosestSide; 191f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) bool shouldSerializeRadiusYValue = false; 192f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 193f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (m_radiusY) { 194f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) shouldSerializeRadiusYValue = m_radiusY->getValueID() != CSSValueClosestSide; 195f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (shouldSerializeRadiusYValue) 196f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) radiusY = m_radiusY->cssText(); 197f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) } 198f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (shouldSerializeRadiusXValue || (!shouldSerializeRadiusXValue && shouldSerializeRadiusYValue)) 199f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) radiusX = m_radiusX->cssText(); 200f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) } 201f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 202f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) return buildEllipseString(radiusX, radiusY, 203d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) serializePositionOffset(*normalizedCX->getPairValue(), *normalizedCY->getPairValue()), 204d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) serializePositionOffset(*normalizedCY->getPairValue(), *normalizedCX->getPairValue()), 205aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch m_referenceBox ? m_referenceBox->cssText() : String()); 2065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 208926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const 209926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){ 2105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) if (shape.type() != CSSBasicShapeEllipseType) 211926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return false; 212926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 213926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&>(shape); 214926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return compareCSSValuePtr(m_centerX, other.m_centerX) 215926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) && compareCSSValuePtr(m_centerY, other.m_centerY) 216926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) && compareCSSValuePtr(m_radiusX, other.m_radiusX) 21709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_radiusY, other.m_radiusY) 218aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch && compareCSSValuePtr(m_referenceBox, other.m_referenceBox); 219926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 220926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 221d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void CSSBasicShapeEllipse::trace(Visitor* visitor) 222d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 223d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_centerX); 224d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_centerY); 225d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_radiusX); 226d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_radiusY); 227d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) CSSBasicShape::trace(visitor); 228d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 229d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 230aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdochstatic String buildPolygonString(const WindRule& windRule, const Vector<String>& points, const String& box) 2315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ASSERT(!(points.size() % 2)); 2335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) StringBuilder result; 23509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const char evenOddOpening[] = "polygon(evenodd, "; 236d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) const char nonZeroOpening[] = "polygon("; 23709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const char commaSeparator[] = ", "; 238d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) COMPILE_ASSERT(sizeof(evenOddOpening) > sizeof(nonZeroOpening), polygon_string_openings_have_same_length); 23902772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Compute the required capacity in advance to reduce allocations. 2415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) size_t length = sizeof(evenOddOpening) - 1; 2425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (size_t i = 0; i < points.size(); i += 2) { 2435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (i) 2445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) length += (sizeof(commaSeparator) - 1); 2455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // add length of two strings, plus one for the space separator. 2465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) length += points[i].length() + 1 + points[i + 1].length(); 2475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 248aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch if (!box.isEmpty()) 249aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch length += box.length() + 1; 2505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.reserveCapacity(length); 2515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (windRule == RULE_EVENODD) 2535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.appendLiteral(evenOddOpening); 2545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) else 2555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.appendLiteral(nonZeroOpening); 2565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (size_t i = 0; i < points.size(); i += 2) { 2585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (i) 2595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.appendLiteral(commaSeparator); 2605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.append(points[i]); 2615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.append(' '); 2625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.append(points[i + 1]); 2635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) result.append(')'); 2665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 267aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch if (!box.isEmpty()) { 26809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(' '); 269aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch result.append(box); 27009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 27109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 2725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return result.toString(); 2735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)String CSSBasicShapePolygon::cssText() const 2765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Vector<String> points; 2785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) points.reserveInitialCapacity(m_values.size()); 2795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (size_t i = 0; i < m_values.size(); ++i) 2815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) points.append(m_values.at(i)->cssText()); 2825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 283aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch return buildPolygonString(m_windRule, points, m_referenceBox ? m_referenceBox->cssText() : String()); 2845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 286926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)bool CSSBasicShapePolygon::equals(const CSSBasicShape& shape) const 287926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){ 2885267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) if (shape.type() != CSSBasicShapePolygonType) 289926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return false; 290926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 291926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) const CSSBasicShapePolygon& rhs = static_cast<const CSSBasicShapePolygon&>(shape); 2925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 293aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch if (!compareCSSValuePtr(m_referenceBox, rhs.m_referenceBox)) 29409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return false; 2955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 296d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return compareCSSValueVector(m_values, rhs.m_values); 297d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 298d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 299d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void CSSBasicShapePolygon::trace(Visitor* visitor) 300d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 301d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_values); 302d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) CSSBasicShape::trace(visitor); 3035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 305a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdochstatic bool buildInsetRadii(Vector<String> &radii, const String& topLeftRadius, const String& topRightRadius, const String& bottomRightRadius, const String& bottomLeftRadius) 306a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch{ 307a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool showBottomLeft = topRightRadius != bottomLeftRadius; 308a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool showBottomRight = showBottomLeft || (bottomRightRadius != topLeftRadius); 309a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool showTopRight = showBottomRight || (topRightRadius != topLeftRadius); 310a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 311a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch radii.append(topLeftRadius); 312a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (showTopRight) 313a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch radii.append(topRightRadius); 314a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (showBottomRight) 315a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch radii.append(bottomRightRadius); 316a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (showBottomLeft) 317a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch radii.append(bottomLeftRadius); 318a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 319a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch return radii.size() == 1 && radii[0] == "0px"; 320a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch} 321a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 32209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static String buildInsetString(const String& top, const String& right, const String& bottom, const String& left, 32309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const String& topLeftRadiusWidth, const String& topLeftRadiusHeight, 32409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const String& topRightRadiusWidth, const String& topRightRadiusHeight, 32509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight, 32609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight) 3275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles){ 32809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char opening[] = "inset("; 32909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char separator[] = " "; 33009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) char cornersSeparator[] = "round"; 33109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) StringBuilder result; 33209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(opening); 33309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(top); 334a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool showLeftArg = !left.isNull() && left != right; 335a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool showBottomArg = !bottom.isNull() && (bottom != top || showLeftArg); 336a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool showRightArg = !right.isNull() && (right != top || showBottomArg); 337a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (showRightArg) { 33809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 33909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(right); 34009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 341a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (showBottomArg) { 34209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 34309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(bottom); 34409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 345a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (showLeftArg) { 34609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.appendLiteral(separator); 34709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(left); 34809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 34909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 35009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { 351a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch Vector<String> horizontalRadii; 352a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool areDefaultCornerRadii = buildInsetRadii(horizontalRadii, topLeftRadiusWidth, topRightRadiusWidth, bottomRightRadiusWidth, bottomLeftRadiusWidth); 35309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 354a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch Vector<String> verticalRadii; 355a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch areDefaultCornerRadii &= buildInsetRadii(verticalRadii, topLeftRadiusHeight, topRightRadiusHeight, bottomRightRadiusHeight, bottomLeftRadiusHeight); 35609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 357a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (!areDefaultCornerRadii) { 358a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.appendLiteral(separator); 359a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.appendLiteral(cornersSeparator); 360a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 361a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch for (size_t i = 0; i < horizontalRadii.size(); ++i) { 362a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.appendLiteral(separator); 363a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.append(horizontalRadii[i]); 364a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch } 365a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (horizontalRadii != verticalRadii) { 366a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.appendLiteral(separator); 367a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.appendLiteral("/"); 368a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 369a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch for (size_t i = 0; i < verticalRadii.size(); ++i) { 370a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.appendLiteral(separator); 371a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch result.append(verticalRadii[i]); 372a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch } 373a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch } 374a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch } 37509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 37609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) result.append(')'); 37709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 37809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return result.toString(); 37909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 38009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 38109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static inline void updateCornerRadiusWidthAndHeight(CSSPrimitiveValue* corner, String& width, String& height) 38209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 38309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!corner) 38409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return; 38509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 38609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) Pair* radius = corner->getPairValue(); 38709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) width = radius->first() ? radius->first()->cssText() : String("0"); 38809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (radius->second()) 38909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) height = radius->second()->cssText(); 39009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 39109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 39209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)String CSSBasicShapeInset::cssText() const 39309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 39409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String topLeftRadiusWidth; 39509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String topLeftRadiusHeight; 39609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String topRightRadiusWidth; 39709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String topRightRadiusHeight; 39809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String bottomRightRadiusWidth; 39909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String bottomRightRadiusHeight; 40009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String bottomLeftRadiusWidth; 40109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String bottomLeftRadiusHeight; 40209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 40309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) updateCornerRadiusWidthAndHeight(topLeftRadius(), topLeftRadiusWidth, topLeftRadiusHeight); 40409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) updateCornerRadiusWidthAndHeight(topRightRadius(), topRightRadiusWidth, topRightRadiusHeight); 40509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) updateCornerRadiusWidthAndHeight(bottomRightRadius(), bottomRightRadiusWidth, bottomRightRadiusHeight); 40609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) updateCornerRadiusWidthAndHeight(bottomLeftRadius(), bottomLeftRadiusWidth, bottomLeftRadiusHeight); 40709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 40809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return buildInsetString(m_top ? m_top->cssText() : String(), 40909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_right ? m_right->cssText() : String(), 41009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_bottom ? m_bottom->cssText() : String(), 41109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_left ? m_left->cssText() : String(), 41209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) topLeftRadiusWidth, 41309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) topLeftRadiusHeight, 41409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) topRightRadiusWidth, 41509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) topRightRadiusHeight, 41609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bottomRightRadiusWidth, 41709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bottomRightRadiusHeight, 41809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bottomLeftRadiusWidth, 41909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bottomLeftRadiusHeight); 4205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 4215267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 42209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)bool CSSBasicShapeInset::equals(const CSSBasicShape& shape) const 4235267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles){ 42409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (shape.type() != CSSBasicShapeInsetType) 42509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return false; 42609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 42709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const CSSBasicShapeInset& other = static_cast<const CSSBasicShapeInset&>(shape); 42809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return compareCSSValuePtr(m_top, other.m_top) 42909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_right, other.m_right) 43009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_bottom, other.m_bottom) 43109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_left, other.m_left) 43209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_topLeftRadius, other.m_topLeftRadius) 43309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_topRightRadius, other.m_topRightRadius) 43409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_bottomRightRadius, other.m_bottomRightRadius) 43509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) && compareCSSValuePtr(m_bottomLeftRadius, other.m_bottomLeftRadius); 4365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 4375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 438d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void CSSBasicShapeInset::trace(Visitor* visitor) 439d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 440d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_top); 441d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_right); 442d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_bottom); 443d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_left); 444d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_topLeftRadius); 445d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_topRightRadius); 446d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_bottomRightRadius); 447d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) visitor->trace(m_bottomLeftRadius); 448d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) CSSBasicShape::trace(visitor); 449d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 450d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 451c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 4525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 453