| Index: Source/core/css/TransformBuilder.cpp
|
| diff --git a/Source/core/css/TransformBuilder.cpp b/Source/core/css/TransformBuilder.cpp
|
| deleted file mode 100644
|
| index 4c3825b231f9d114449b3476f45ad4cd647dcf47..0000000000000000000000000000000000000000
|
| --- a/Source/core/css/TransformBuilder.cpp
|
| +++ /dev/null
|
| @@ -1,336 +0,0 @@
|
| -/*
|
| - * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
|
| - * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
|
| - * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
|
| - * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
|
| - * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
|
| - * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
|
| - * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
|
| - * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
|
| - * Copyright (C) Research In Motion Limited 2011. All rights reserved.
|
| - * Copyright (C) 2012 Google Inc. All rights reserved.
|
| - *
|
| - * This library is free software; you can redistribute it and/or
|
| - * modify it under the terms of the GNU Library General Public
|
| - * License as published by the Free Software Foundation; either
|
| - * version 2 of the License, or (at your option) any later version.
|
| - *
|
| - * This library is distributed in the hope that it will be useful,
|
| - * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| - * Library General Public License for more details.
|
| - *
|
| - * You should have received a copy of the GNU Library General Public License
|
| - * along with this library; see the file COPYING.LIB. If not, write to
|
| - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| - * Boston, MA 02110-1301, USA.
|
| - */
|
| -
|
| -#include "config.h"
|
| -#include "core/css/TransformBuilder.h"
|
| -
|
| -#include "core/css/WebKitCSSTransformValue.h"
|
| -#include "core/rendering/style/RenderStyle.h"
|
| -#include "core/platform/graphics/transforms/Matrix3DTransformOperation.h"
|
| -#include "core/platform/graphics/transforms/MatrixTransformOperation.h"
|
| -#include "core/platform/graphics/transforms/PerspectiveTransformOperation.h"
|
| -#include "core/platform/graphics/transforms/RotateTransformOperation.h"
|
| -#include "core/platform/graphics/transforms/ScaleTransformOperation.h"
|
| -#include "core/platform/graphics/transforms/SkewTransformOperation.h"
|
| -#include "core/platform/graphics/transforms/TransformationMatrix.h"
|
| -#include "core/platform/graphics/transforms/TranslateTransformOperation.h"
|
| -
|
| -#include "core/css/WebKitCSSFilterValue.h"
|
| -#include "core/platform/graphics/filters/FilterOperation.h"
|
| -#include "core/css/CSSPrimitiveValueMappings.h"
|
| -
|
| -namespace WebCore {
|
| -
|
| -TransformBuilder::TransformBuilder()
|
| -{
|
| -}
|
| -
|
| -TransformBuilder::~TransformBuilder()
|
| -{
|
| -}
|
| -
|
| -static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
|
| -{
|
| - return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
|
| -}
|
| -
|
| -static TransformOperation::OperationType getTransformOperationType(WebKitCSSTransformValue::TransformOperationType type)
|
| -{
|
| - switch (type) {
|
| - case WebKitCSSTransformValue::ScaleTransformOperation: return TransformOperation::SCALE;
|
| - case WebKitCSSTransformValue::ScaleXTransformOperation: return TransformOperation::SCALE_X;
|
| - case WebKitCSSTransformValue::ScaleYTransformOperation: return TransformOperation::SCALE_Y;
|
| - case WebKitCSSTransformValue::ScaleZTransformOperation: return TransformOperation::SCALE_Z;
|
| - case WebKitCSSTransformValue::Scale3DTransformOperation: return TransformOperation::SCALE_3D;
|
| - case WebKitCSSTransformValue::TranslateTransformOperation: return TransformOperation::TRANSLATE;
|
| - case WebKitCSSTransformValue::TranslateXTransformOperation: return TransformOperation::TRANSLATE_X;
|
| - case WebKitCSSTransformValue::TranslateYTransformOperation: return TransformOperation::TRANSLATE_Y;
|
| - case WebKitCSSTransformValue::TranslateZTransformOperation: return TransformOperation::TRANSLATE_Z;
|
| - case WebKitCSSTransformValue::Translate3DTransformOperation: return TransformOperation::TRANSLATE_3D;
|
| - case WebKitCSSTransformValue::RotateTransformOperation: return TransformOperation::ROTATE;
|
| - case WebKitCSSTransformValue::RotateXTransformOperation: return TransformOperation::ROTATE_X;
|
| - case WebKitCSSTransformValue::RotateYTransformOperation: return TransformOperation::ROTATE_Y;
|
| - case WebKitCSSTransformValue::RotateZTransformOperation: return TransformOperation::ROTATE_Z;
|
| - case WebKitCSSTransformValue::Rotate3DTransformOperation: return TransformOperation::ROTATE_3D;
|
| - case WebKitCSSTransformValue::SkewTransformOperation: return TransformOperation::SKEW;
|
| - case WebKitCSSTransformValue::SkewXTransformOperation: return TransformOperation::SKEW_X;
|
| - case WebKitCSSTransformValue::SkewYTransformOperation: return TransformOperation::SKEW_Y;
|
| - case WebKitCSSTransformValue::MatrixTransformOperation: return TransformOperation::MATRIX;
|
| - case WebKitCSSTransformValue::Matrix3DTransformOperation: return TransformOperation::MATRIX_3D;
|
| - case WebKitCSSTransformValue::PerspectiveTransformOperation: return TransformOperation::PERSPECTIVE;
|
| - case WebKitCSSTransformValue::UnknownTransformOperation: return TransformOperation::NONE;
|
| - }
|
| - return TransformOperation::NONE;
|
| -}
|
| -
|
| -bool TransformBuilder::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
|
| -{
|
| - if (!inValue || !inValue->isValueList()) {
|
| - outOperations.clear();
|
| - return false;
|
| - }
|
| -
|
| - float zoomFactor = style ? style->effectiveZoom() : 1;
|
| - TransformOperations operations;
|
| - for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) {
|
| - CSSValue* currValue = i.value();
|
| -
|
| - if (!currValue->isWebKitCSSTransformValue())
|
| - continue;
|
| -
|
| - WebKitCSSTransformValue* transformValue = static_cast<WebKitCSSTransformValue*>(i.value());
|
| - if (!transformValue->length())
|
| - continue;
|
| -
|
| - bool haveNonPrimitiveValue = false;
|
| - for (unsigned j = 0; j < transformValue->length(); ++j) {
|
| - if (!transformValue->itemWithoutBoundsCheck(j)->isPrimitiveValue()) {
|
| - haveNonPrimitiveValue = true;
|
| - break;
|
| - }
|
| - }
|
| - if (haveNonPrimitiveValue)
|
| - continue;
|
| -
|
| - CSSPrimitiveValue* firstValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(0));
|
| -
|
| - switch (transformValue->operationType()) {
|
| - case WebKitCSSTransformValue::ScaleTransformOperation:
|
| - case WebKitCSSTransformValue::ScaleXTransformOperation:
|
| - case WebKitCSSTransformValue::ScaleYTransformOperation: {
|
| - double sx = 1.0;
|
| - double sy = 1.0;
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::ScaleYTransformOperation)
|
| - sy = firstValue->getDoubleValue();
|
| - else {
|
| - sx = firstValue->getDoubleValue();
|
| - if (transformValue->operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) {
|
| - if (transformValue->length() > 1) {
|
| - CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
|
| - sy = secondValue->getDoubleValue();
|
| - } else
|
| - sy = sx;
|
| - }
|
| - }
|
| - operations.operations().append(ScaleTransformOperation::create(sx, sy, 1.0, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::ScaleZTransformOperation:
|
| - case WebKitCSSTransformValue::Scale3DTransformOperation: {
|
| - double sx = 1.0;
|
| - double sy = 1.0;
|
| - double sz = 1.0;
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::ScaleZTransformOperation)
|
| - sz = firstValue->getDoubleValue();
|
| - else if (transformValue->operationType() == WebKitCSSTransformValue::ScaleYTransformOperation)
|
| - sy = firstValue->getDoubleValue();
|
| - else {
|
| - sx = firstValue->getDoubleValue();
|
| - if (transformValue->operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) {
|
| - if (transformValue->length() > 2) {
|
| - CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
|
| - sz = thirdValue->getDoubleValue();
|
| - }
|
| - if (transformValue->length() > 1) {
|
| - CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
|
| - sy = secondValue->getDoubleValue();
|
| - } else
|
| - sy = sx;
|
| - }
|
| - }
|
| - operations.operations().append(ScaleTransformOperation::create(sx, sy, sz, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::TranslateTransformOperation:
|
| - case WebKitCSSTransformValue::TranslateXTransformOperation:
|
| - case WebKitCSSTransformValue::TranslateYTransformOperation: {
|
| - Length tx = Length(0, Fixed);
|
| - Length ty = Length(0, Fixed);
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
|
| - ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
|
| - else {
|
| - tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
|
| - if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
|
| - if (transformValue->length() > 1) {
|
| - CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
|
| - ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
|
| - }
|
| - }
|
| - }
|
| -
|
| - if (tx.isUndefined() || ty.isUndefined())
|
| - return false;
|
| -
|
| - operations.operations().append(TranslateTransformOperation::create(tx, ty, Length(0, Fixed), getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::TranslateZTransformOperation:
|
| - case WebKitCSSTransformValue::Translate3DTransformOperation: {
|
| - Length tx = Length(0, Fixed);
|
| - Length ty = Length(0, Fixed);
|
| - Length tz = Length(0, Fixed);
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
|
| - tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
|
| - else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
|
| - ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
|
| - else {
|
| - tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
|
| - if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
|
| - if (transformValue->length() > 2) {
|
| - CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
|
| - tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor);
|
| - }
|
| - if (transformValue->length() > 1) {
|
| - CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
|
| - ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
|
| - }
|
| - }
|
| - }
|
| -
|
| - if (tx.isUndefined() || ty.isUndefined() || tz.isUndefined())
|
| - return false;
|
| -
|
| - operations.operations().append(TranslateTransformOperation::create(tx, ty, tz, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::RotateTransformOperation: {
|
| - double angle = firstValue->computeDegrees();
|
| - operations.operations().append(RotateTransformOperation::create(0, 0, 1, angle, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::RotateXTransformOperation:
|
| - case WebKitCSSTransformValue::RotateYTransformOperation:
|
| - case WebKitCSSTransformValue::RotateZTransformOperation: {
|
| - double x = 0;
|
| - double y = 0;
|
| - double z = 0;
|
| - double angle = firstValue->computeDegrees();
|
| -
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::RotateXTransformOperation)
|
| - x = 1;
|
| - else if (transformValue->operationType() == WebKitCSSTransformValue::RotateYTransformOperation)
|
| - y = 1;
|
| - else
|
| - z = 1;
|
| - operations.operations().append(RotateTransformOperation::create(x, y, z, angle, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::Rotate3DTransformOperation: {
|
| - if (transformValue->length() < 4)
|
| - break;
|
| - CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
|
| - CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
|
| - CSSPrimitiveValue* fourthValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(3));
|
| - double x = firstValue->getDoubleValue();
|
| - double y = secondValue->getDoubleValue();
|
| - double z = thirdValue->getDoubleValue();
|
| - double angle = fourthValue->computeDegrees();
|
| - operations.operations().append(RotateTransformOperation::create(x, y, z, angle, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::SkewTransformOperation:
|
| - case WebKitCSSTransformValue::SkewXTransformOperation:
|
| - case WebKitCSSTransformValue::SkewYTransformOperation: {
|
| - double angleX = 0;
|
| - double angleY = 0;
|
| - double angle = firstValue->computeDegrees();
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::SkewYTransformOperation)
|
| - angleY = angle;
|
| - else {
|
| - angleX = angle;
|
| - if (transformValue->operationType() == WebKitCSSTransformValue::SkewTransformOperation) {
|
| - if (transformValue->length() > 1) {
|
| - CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
|
| - angleY = secondValue->computeDegrees();
|
| - }
|
| - }
|
| - }
|
| - operations.operations().append(SkewTransformOperation::create(angleX, angleY, getTransformOperationType(transformValue->operationType())));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::MatrixTransformOperation: {
|
| - if (transformValue->length() < 6)
|
| - break;
|
| - double a = firstValue->getDoubleValue();
|
| - double b = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1))->getDoubleValue();
|
| - double c = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2))->getDoubleValue();
|
| - double d = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(3))->getDoubleValue();
|
| - double e = zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(4))->getDoubleValue();
|
| - double f = zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(5))->getDoubleValue();
|
| - operations.operations().append(MatrixTransformOperation::create(a, b, c, d, e, f));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::Matrix3DTransformOperation: {
|
| - if (transformValue->length() < 16)
|
| - break;
|
| - TransformationMatrix matrix(static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(0))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(3))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(4))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(5))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(6))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(7))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(8))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(9))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(10))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(11))->getDoubleValue(),
|
| - zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(12))->getDoubleValue(),
|
| - zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(13))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(14))->getDoubleValue(),
|
| - static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(15))->getDoubleValue());
|
| - operations.operations().append(Matrix3DTransformOperation::create(matrix));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::PerspectiveTransformOperation: {
|
| - Length p = Length(0, Fixed);
|
| - if (firstValue->isLength())
|
| - p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
|
| - else {
|
| - // This is a quirk that should go away when 3d transforms are finalized.
|
| - double val = firstValue->getDoubleValue();
|
| - p = val >= 0 ? Length(clampToPositiveInteger(val), Fixed) : Length(Undefined);
|
| - }
|
| -
|
| - if (p.isUndefined())
|
| - return false;
|
| -
|
| - operations.operations().append(PerspectiveTransformOperation::create(p));
|
| - break;
|
| - }
|
| - case WebKitCSSTransformValue::UnknownTransformOperation:
|
| - ASSERT_NOT_REACHED();
|
| - break;
|
| - }
|
| - }
|
| -
|
| - outOperations = operations;
|
| - return true;
|
| -}
|
| -
|
| -} // namespace WebCore
|
|
|