Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2482753002: Fix matrix3d transform under page zoom (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
7 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 7 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
8 * Copyright (C) 2015 Google Inc. All rights reserved. 8 * Copyright (C) 2015 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 inline static CSSValue* zoomAdjustedPixelValueOrAuto( 85 inline static CSSValue* zoomAdjustedPixelValueOrAuto(
86 const Length& length, 86 const Length& length,
87 const ComputedStyle& style) { 87 const ComputedStyle& style) {
88 if (length.isAuto()) 88 if (length.isAuto())
89 return CSSIdentifierValue::create(CSSValueAuto); 89 return CSSIdentifierValue::create(CSSValueAuto);
90 return zoomAdjustedPixelValue(length.value(), style); 90 return zoomAdjustedPixelValue(length.value(), style);
91 } 91 }
92 92
93 inline static CSSPrimitiveValue* zoomAdjustedNumberValue(
94 double value,
95 const ComputedStyle& style) {
96 return CSSPrimitiveValue::create(value / style.effectiveZoom(),
97 CSSPrimitiveValue::UnitType::Number);
98 }
99
100 static CSSValue* zoomAdjustedPixelValueForLength(const Length& length, 93 static CSSValue* zoomAdjustedPixelValueForLength(const Length& length,
101 const ComputedStyle& style) { 94 const ComputedStyle& style) {
102 if (length.isFixed()) 95 if (length.isFixed())
103 return zoomAdjustedPixelValue(length.value(), style); 96 return zoomAdjustedPixelValue(length.value(), style);
104 return CSSValue::create(length, style.effectiveZoom()); 97 return CSSValue::create(length, style.effectiveZoom());
105 } 98 }
106 99
107 static CSSValue* pixelValueForUnzoomedLength( 100 static CSSValue* pixelValueForUnzoomedLength(
108 const UnzoomedLength& unzoomedLength, 101 const UnzoomedLength& unzoomedLength,
109 const ComputedStyle& style) { 102 const ComputedStyle& style) {
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 CSSValueList& list = *valuesForBorderRadiusCorner(radius, style); 1342 CSSValueList& list = *valuesForBorderRadiusCorner(radius, style);
1350 if (list.item(0).equals(list.item(1))) 1343 if (list.item(0).equals(list.item(1)))
1351 return list.item(0); 1344 return list.item(0);
1352 return list; 1345 return list;
1353 } 1346 }
1354 1347
1355 static CSSFunctionValue* valueForMatrixTransform( 1348 static CSSFunctionValue* valueForMatrixTransform(
1356 const TransformationMatrix& transform, 1349 const TransformationMatrix& transform,
1357 const ComputedStyle& style) { 1350 const ComputedStyle& style) {
1358 CSSFunctionValue* transformValue = nullptr; 1351 CSSFunctionValue* transformValue = nullptr;
1352 double zoomFactor = style.effectiveZoom();
pdr. 2016/11/08 07:04:08 I wonder if we could simplify this by moving it up
Franklin Ta 2016/11/08 07:52:18 There are a lot of other functions in this file in
Franklin Ta 2016/11/08 16:47:02 Terminology note: I just noticed you guys define T
1359 if (transform.isAffine()) { 1353 if (transform.isAffine()) {
1360 transformValue = CSSFunctionValue::create(CSSValueMatrix); 1354 transformValue = CSSFunctionValue::create(CSSValueMatrix);
1361 1355
1362 transformValue->append(*CSSPrimitiveValue::create( 1356 transformValue->append(*CSSPrimitiveValue::create(
1363 transform.a(), CSSPrimitiveValue::UnitType::Number)); 1357 transform.a(), CSSPrimitiveValue::UnitType::Number));
1364 transformValue->append(*CSSPrimitiveValue::create( 1358 transformValue->append(*CSSPrimitiveValue::create(
1365 transform.b(), CSSPrimitiveValue::UnitType::Number)); 1359 transform.b(), CSSPrimitiveValue::UnitType::Number));
1366 transformValue->append(*CSSPrimitiveValue::create( 1360 transformValue->append(*CSSPrimitiveValue::create(
1367 transform.c(), CSSPrimitiveValue::UnitType::Number)); 1361 transform.c(), CSSPrimitiveValue::UnitType::Number));
1368 transformValue->append(*CSSPrimitiveValue::create( 1362 transformValue->append(*CSSPrimitiveValue::create(
1369 transform.d(), CSSPrimitiveValue::UnitType::Number)); 1363 transform.d(), CSSPrimitiveValue::UnitType::Number));
1370 transformValue->append(*zoomAdjustedNumberValue(transform.e(), style)); 1364 transformValue->append(*CSSPrimitiveValue::create(
1371 transformValue->append(*zoomAdjustedNumberValue(transform.f(), style)); 1365 transform.e() / zoomFactor, CSSPrimitiveValue::UnitType::Number));
1366 transformValue->append(*CSSPrimitiveValue::create(
1367 transform.f() / zoomFactor, CSSPrimitiveValue::UnitType::Number));
1372 } else { 1368 } else {
1373 transformValue = CSSFunctionValue::create(CSSValueMatrix3d); 1369 transformValue = CSSFunctionValue::create(CSSValueMatrix3d);
1374 1370
1375 transformValue->append(*CSSPrimitiveValue::create( 1371 transformValue->append(*CSSPrimitiveValue::create(
1376 transform.m11(), CSSPrimitiveValue::UnitType::Number)); 1372 transform.m11(), CSSPrimitiveValue::UnitType::Number));
1377 transformValue->append(*CSSPrimitiveValue::create( 1373 transformValue->append(*CSSPrimitiveValue::create(
1378 transform.m12(), CSSPrimitiveValue::UnitType::Number)); 1374 transform.m12(), CSSPrimitiveValue::UnitType::Number));
1379 transformValue->append(*CSSPrimitiveValue::create( 1375 transformValue->append(*CSSPrimitiveValue::create(
1380 transform.m13(), CSSPrimitiveValue::UnitType::Number)); 1376 transform.m13(), CSSPrimitiveValue::UnitType::Number));
1381 transformValue->append(*CSSPrimitiveValue::create( 1377 transformValue->append(*CSSPrimitiveValue::create(
1382 transform.m14(), CSSPrimitiveValue::UnitType::Number)); 1378 transform.m14() * zoomFactor, CSSPrimitiveValue::UnitType::Number));
1383 1379
1384 transformValue->append(*CSSPrimitiveValue::create( 1380 transformValue->append(*CSSPrimitiveValue::create(
1385 transform.m21(), CSSPrimitiveValue::UnitType::Number)); 1381 transform.m21(), CSSPrimitiveValue::UnitType::Number));
1386 transformValue->append(*CSSPrimitiveValue::create( 1382 transformValue->append(*CSSPrimitiveValue::create(
1387 transform.m22(), CSSPrimitiveValue::UnitType::Number)); 1383 transform.m22(), CSSPrimitiveValue::UnitType::Number));
1388 transformValue->append(*CSSPrimitiveValue::create( 1384 transformValue->append(*CSSPrimitiveValue::create(
1389 transform.m23(), CSSPrimitiveValue::UnitType::Number)); 1385 transform.m23(), CSSPrimitiveValue::UnitType::Number));
1390 transformValue->append(*CSSPrimitiveValue::create( 1386 transformValue->append(*CSSPrimitiveValue::create(
1391 transform.m24(), CSSPrimitiveValue::UnitType::Number)); 1387 transform.m24() * zoomFactor, CSSPrimitiveValue::UnitType::Number));
1392 1388
1393 transformValue->append(*CSSPrimitiveValue::create( 1389 transformValue->append(*CSSPrimitiveValue::create(
1394 transform.m31(), CSSPrimitiveValue::UnitType::Number)); 1390 transform.m31(), CSSPrimitiveValue::UnitType::Number));
1395 transformValue->append(*CSSPrimitiveValue::create( 1391 transformValue->append(*CSSPrimitiveValue::create(
1396 transform.m32(), CSSPrimitiveValue::UnitType::Number)); 1392 transform.m32(), CSSPrimitiveValue::UnitType::Number));
1397 transformValue->append(*CSSPrimitiveValue::create( 1393 transformValue->append(*CSSPrimitiveValue::create(
1398 transform.m33(), CSSPrimitiveValue::UnitType::Number)); 1394 transform.m33(), CSSPrimitiveValue::UnitType::Number));
1399 transformValue->append(*CSSPrimitiveValue::create( 1395 transformValue->append(*CSSPrimitiveValue::create(
1400 transform.m34(), CSSPrimitiveValue::UnitType::Number)); 1396 transform.m34() * zoomFactor, CSSPrimitiveValue::UnitType::Number));
1401 1397
1402 transformValue->append(*zoomAdjustedNumberValue(transform.m41(), style)); 1398 transformValue->append(*CSSPrimitiveValue::create(
1403 transformValue->append(*zoomAdjustedNumberValue(transform.m42(), style)); 1399 transform.m41() / zoomFactor, CSSPrimitiveValue::UnitType::Number));
1404 transformValue->append(*zoomAdjustedNumberValue(transform.m43(), style)); 1400 transformValue->append(*CSSPrimitiveValue::create(
1401 transform.m42() / zoomFactor, CSSPrimitiveValue::UnitType::Number));
1402 transformValue->append(*CSSPrimitiveValue::create(
1403 transform.m43() / zoomFactor, CSSPrimitiveValue::UnitType::Number));
alancutter (OOO until 2018) 2016/11/09 02:35:59 I'd push the Matrix3DTransformOperation::zoom() lo
Franklin Ta 2016/11/09 07:12:06 This is a great idea and tidies up everything! Don
1405 transformValue->append(*CSSPrimitiveValue::create( 1404 transformValue->append(*CSSPrimitiveValue::create(
1406 transform.m44(), CSSPrimitiveValue::UnitType::Number)); 1405 transform.m44(), CSSPrimitiveValue::UnitType::Number));
1407 } 1406 }
1408 1407
1409 return transformValue; 1408 return transformValue;
1410 } 1409 }
1411 1410
1412 static CSSValue* computedTransform(const LayoutObject* layoutObject, 1411 static CSSValue* computedTransform(const LayoutObject* layoutObject,
1413 const ComputedStyle& style) { 1412 const ComputedStyle& style) {
1414 if (!layoutObject || !style.hasTransform()) 1413 if (!layoutObject || !style.hasTransform())
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 case CSSPropertyAll: 3618 case CSSPropertyAll:
3620 return nullptr; 3619 return nullptr;
3621 default: 3620 default:
3622 break; 3621 break;
3623 } 3622 }
3624 ASSERT_NOT_REACHED(); 3623 ASSERT_NOT_REACHED();
3625 return nullptr; 3624 return nullptr;
3626 } 3625 }
3627 3626
3628 } // namespace blink 3627 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698