COMMIT_MESSAGE

 1Make WebKitCSSMatrix more efficient for use in WebGL
 2

LayoutTests/ChangeLog

 12011-10-19 Igor Oliveira <igor.oliveira@openbossa.org>
 2
 3 Make WebKitCSSMatrix more efficient for use in WebGL
 4 https://bugs.webkit.org/show_bug.cgi?id=50633
 5
 6 Add tests for the mutable methods in WebKitCSSMatrix.
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 * transforms/cssmatrix-3d-interface-expected.txt:
 11 * transforms/cssmatrix-3d-interface.xhtml:
 12
1132011-10-18 Dirk Pranke <dpranke@chromium.org>
214
315 Add a new chromium baseline for fast/multicol/vertical-rl/rule-style.html.

LayoutTests/transforms/cssmatrix-3d-interface-expected.txt

@@PASS m.m42 is 0
180180PASS m.m43 is 0
181181PASS m.m44 is 1
182182
 183Test multipliedBy
 184PASS parseFloat(m.m11) is 538
 185PASS parseFloat(m.m12) is 612
 186PASS parseFloat(m.m13) is 686
 187PASS parseFloat(m.m14) is 760
 188PASS parseFloat(m.m21) is 650
 189PASS parseFloat(m.m22) is 740
 190PASS parseFloat(m.m23) is 830
 191PASS parseFloat(m.m24) is 920
 192PASS parseFloat(m.m31) is 762
 193PASS parseFloat(m.m32) is 868
 194PASS parseFloat(m.m33) is 974
 195PASS parseFloat(m.m34) is 1080
 196PASS parseFloat(m.m41) is 874
 197PASS parseFloat(m.m42) is 996
 198PASS parseFloat(m.m43) is 1118
 199PASS parseFloat(m.m44) is 1240
 200
183201Test inverse
184202PASS parseFloat(m2.m11) is 0.5
185203PASS parseFloat(m2.m12) is 0

@@PASS m.m42 is 0
255273PASS m.m43 is 0
256274PASS m.m44 is 1
257275
 276Test translatedBy
 277PASS m.m11 is 1
 278PASS m.m12 is 0
 279PASS m.m13 is 0
 280PASS m.m14 is 0
 281PASS m.m21 is 0
 282PASS m.m22 is 1
 283PASS m.m23 is 0
 284PASS m.m24 is 0
 285PASS m.m31 is 0
 286PASS m.m32 is 0
 287PASS m.m33 is 1
 288PASS m.m34 is 0
 289PASS m.m41 is 10
 290PASS m.m42 is 20
 291PASS m.m43 is 30
 292PASS m.m44 is 1
 293
258294Test scale
259295PASS m2.m11 is 10
260296PASS m2.m12 is 0

@@PASS m.m42 is 0
291327PASS m.m43 is 0
292328PASS m.m44 is 1
293329
 330Test scaledBy
 331PASS m.m11 is 10
 332PASS m.m12 is 0
 333PASS m.m13 is 0
 334PASS m.m14 is 0
 335PASS m.m21 is 0
 336PASS m.m22 is 20
 337PASS m.m23 is 0
 338PASS m.m24 is 0
 339PASS m.m31 is 0
 340PASS m.m32 is 0
 341PASS m.m33 is 30
 342PASS m.m34 is 0
 343PASS m.m41 is 0
 344PASS m.m42 is 0
 345PASS m.m43 is 0
 346PASS m.m44 is 1
 347
294348Test rotate
295349PASS parseFloat(m2.m11.toPrecision(6)) is 0.813798
296350PASS parseFloat(m2.m12.toPrecision(6)) is 0.469846

@@PASS m.m42 is 0
327381PASS m.m43 is 0
328382PASS m.m44 is 1
329383
 384Test rotatedBy
 385PASS parseFloat(m.m11.toPrecision(6)) is 0.813798
 386PASS parseFloat(m.m12.toPrecision(6)) is 0.469846
 387PASS parseFloat(m.m13.toPrecision(6)) is -0.34202
 388PASS parseFloat(m.m14.toPrecision(6)) is 0
 389PASS parseFloat(m.m21.toPrecision(6)) is -0.44097
 390PASS parseFloat(m.m22.toPrecision(6)) is 0.882564
 391PASS parseFloat(m.m23.toPrecision(6)) is 0.163176
 392PASS parseFloat(m.m24.toPrecision(6)) is 0
 393PASS parseFloat(m.m31.toPrecision(6)) is 0.378522
 394PASS parseFloat(m.m32.toPrecision(6)) is 0.0180283
 395PASS parseFloat(m.m33.toPrecision(6)) is 0.925417
 396PASS parseFloat(m.m34.toPrecision(6)) is 0
 397PASS parseFloat(m.m41.toPrecision(6)) is 0
 398PASS parseFloat(m.m42.toPrecision(6)) is 0
 399PASS parseFloat(m.m43.toPrecision(6)) is 0
 400PASS parseFloat(m.m44.toPrecision(6)) is 1
 401
330402Test rotateAxisAngle
331403PASS parseFloat(m2.m11.toPrecision(6)) is 0.804738
332404PASS parseFloat(m2.m12.toPrecision(6)) is 0.505879

@@PASS m.m42 is 0
363435PASS m.m43 is 0
364436PASS m.m44 is 1
365437
 438Test rotatedAxisAngleBy
 439PASS parseFloat(m.m11.toPrecision(6)) is 0.804738
 440PASS parseFloat(m.m12.toPrecision(6)) is 0.505879
 441PASS parseFloat(m.m13.toPrecision(6)) is -0.310617
 442PASS parseFloat(m.m14.toPrecision(6)) is 0
 443PASS parseFloat(m.m21.toPrecision(6)) is -0.310617
 444PASS parseFloat(m.m22.toPrecision(6)) is 0.804738
 445PASS parseFloat(m.m23.toPrecision(6)) is 0.505879
 446PASS parseFloat(m.m24.toPrecision(6)) is 0
 447PASS parseFloat(m.m31.toPrecision(6)) is 0.505879
 448PASS parseFloat(m.m32.toPrecision(6)) is -0.310617
 449PASS parseFloat(m.m33.toPrecision(6)) is 0.804738
 450PASS parseFloat(m.m34.toPrecision(6)) is 0
 451PASS parseFloat(m.m41.toPrecision(6)) is 0
 452PASS parseFloat(m.m42.toPrecision(6)) is 0
 453PASS parseFloat(m.m43.toPrecision(6)) is 0
 454PASS parseFloat(m.m44.toPrecision(6)) is 1
 455
366456PASS successfullyParsed is true
367457
368458TEST COMPLETE

LayoutTests/transforms/cssmatrix-3d-interface.xhtml

@@shouldBe('m.m43', '0');
237237shouldBe('m.m44', '1');
238238
239239debug("");
 240debug("Test multipliedBy");
 241m = new WebKitCSSMatrix("matrix3d( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)");
 242m2 = new WebKitCSSMatrix("matrix3d(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32)");
 243m.multipliedBy(m2);
 244shouldBe('parseFloat(m.m11)', '538');
 245shouldBe('parseFloat(m.m12)', '612');
 246shouldBe('parseFloat(m.m13)', '686');
 247shouldBe('parseFloat(m.m14)', '760');
 248shouldBe('parseFloat(m.m21)', '650');
 249shouldBe('parseFloat(m.m22)', '740');
 250shouldBe('parseFloat(m.m23)', '830');
 251shouldBe('parseFloat(m.m24)', '920');
 252shouldBe('parseFloat(m.m31)', '762');
 253shouldBe('parseFloat(m.m32)', '868');
 254shouldBe('parseFloat(m.m33)', '974');
 255shouldBe('parseFloat(m.m34)', '1080');
 256shouldBe('parseFloat(m.m41)', '874');
 257shouldBe('parseFloat(m.m42)', '996');
 258shouldBe('parseFloat(m.m43)', '1118');
 259shouldBe('parseFloat(m.m44)', '1240');
 260
 261debug("");
240262debug("Test inverse");
241263m = new WebKitCSSMatrix("matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 10, 20, 30, 1)");
242264m2 = m.inverse();

@@shouldBe('m.m43', '0');
323345shouldBe('m.m44', '1');
324346
325347debug("");
 348debug("Test translatedBy");
 349var m = new WebKitCSSMatrix();
 350m.translatedBy(10, 20, 30);
 351shouldBe('m.m11', '1');
 352shouldBe('m.m12', '0');
 353shouldBe('m.m13', '0');
 354shouldBe('m.m14', '0');
 355shouldBe('m.m21', '0');
 356shouldBe('m.m22', '1');
 357shouldBe('m.m23', '0');
 358shouldBe('m.m24', '0');
 359shouldBe('m.m31', '0');
 360shouldBe('m.m32', '0');
 361shouldBe('m.m33', '1');
 362shouldBe('m.m34', '0');
 363shouldBe('m.m41', '10');
 364shouldBe('m.m42', '20');
 365shouldBe('m.m43', '30');
 366shouldBe('m.m44', '1');
 367
 368debug("");
326369debug("Test scale");
327370m = new WebKitCSSMatrix();
328371m2 = m.scale(10, 20, 30);

@@shouldBe('m.m43', '0');
363406shouldBe('m.m44', '1');
364407
365408debug("");
 409debug("Test scaledBy");
 410m = new WebKitCSSMatrix();
 411m.scaledBy(10, 20, 30);
 412shouldBe('m.m11', '10');
 413shouldBe('m.m12', '0');
 414shouldBe('m.m13', '0');
 415shouldBe('m.m14', '0');
 416shouldBe('m.m21', '0');
 417shouldBe('m.m22', '20');
 418shouldBe('m.m23', '0');
 419shouldBe('m.m24', '0');
 420shouldBe('m.m31', '0');
 421shouldBe('m.m32', '0');
 422shouldBe('m.m33', '30');
 423shouldBe('m.m34', '0');
 424shouldBe('m.m41', '0');
 425shouldBe('m.m42', '0');
 426shouldBe('m.m43', '0');
 427shouldBe('m.m44', '1');
 428
 429debug("");
366430debug("Test rotate");
367431m = new WebKitCSSMatrix();
368432m2 = m.rotate(10, 20, 30);

@@shouldBe('m.m43', '0');
403467shouldBe('m.m44', '1');
404468
405469debug("");
 470debug("Test rotatedBy");
 471m = new WebKitCSSMatrix();
 472m.rotatedBy(10, 20, 30);
 473shouldBe('parseFloat(m.m11.toPrecision(6))', '0.813798');
 474shouldBe('parseFloat(m.m12.toPrecision(6))', '0.469846');
 475shouldBe('parseFloat(m.m13.toPrecision(6))', '-0.34202');
 476shouldBe('parseFloat(m.m14.toPrecision(6))', '0');
 477shouldBe('parseFloat(m.m21.toPrecision(6))', '-0.44097');
 478shouldBe('parseFloat(m.m22.toPrecision(6))', '0.882564');
 479shouldBe('parseFloat(m.m23.toPrecision(6))', '0.163176');
 480shouldBe('parseFloat(m.m24.toPrecision(6))', '0');
 481shouldBe('parseFloat(m.m31.toPrecision(6))', '0.378522');
 482shouldBe('parseFloat(m.m32.toPrecision(6))', '0.0180283');
 483shouldBe('parseFloat(m.m33.toPrecision(6))', '0.925417');
 484shouldBe('parseFloat(m.m34.toPrecision(6))', '0');
 485shouldBe('parseFloat(m.m41.toPrecision(6))', '0');
 486shouldBe('parseFloat(m.m42.toPrecision(6))', '0');
 487shouldBe('parseFloat(m.m43.toPrecision(6))', '0');
 488shouldBe('parseFloat(m.m44.toPrecision(6))', '1');
 489
 490
 491debug("");
406492debug("Test rotateAxisAngle");
407493m = new WebKitCSSMatrix();
408494m2 = m.rotateAxisAngle(0.707, 0.707, 0.707, 45);

@@shouldBe('m.m43', '0');
443529shouldBe('m.m44', '1');
444530
445531debug("");
 532debug("Test rotatedAxisAngleBy");
 533m = new WebKitCSSMatrix();
 534m.rotatedAxisAngleBy(0.707, 0.707, 0.707, 45);
 535shouldBe('parseFloat(m.m11.toPrecision(6))', '0.804738');
 536shouldBe('parseFloat(m.m12.toPrecision(6))', '0.505879');
 537shouldBe('parseFloat(m.m13.toPrecision(6))', '-0.310617');
 538shouldBe('parseFloat(m.m14.toPrecision(6))', '0');
 539shouldBe('parseFloat(m.m21.toPrecision(6))', '-0.310617');
 540shouldBe('parseFloat(m.m22.toPrecision(6))', '0.804738');
 541shouldBe('parseFloat(m.m23.toPrecision(6))', '0.505879');
 542shouldBe('parseFloat(m.m24.toPrecision(6))', '0');
 543shouldBe('parseFloat(m.m31.toPrecision(6))', '0.505879');
 544shouldBe('parseFloat(m.m32.toPrecision(6))', '-0.310617');
 545shouldBe('parseFloat(m.m33.toPrecision(6))', '0.804738');
 546shouldBe('parseFloat(m.m34.toPrecision(6))', '0');
 547shouldBe('parseFloat(m.m41.toPrecision(6))', '0');
 548shouldBe('parseFloat(m.m42.toPrecision(6))', '0');
 549shouldBe('parseFloat(m.m43.toPrecision(6))', '0');
 550shouldBe('parseFloat(m.m44.toPrecision(6))', '1');
 551
 552debug("");
446553successfullyParsed = true;
447554
448555</script>

Source/WebCore/ChangeLog

 12011-10-19 Igor Oliveira <igor.oliveira@openbossa.org>
 2
 3 Make WebKitCSSMatrix more efficient for use in WebGL
 4 https://bugs.webkit.org/show_bug.cgi?id=50633
 5
 6 This patch implements mutable methods for WebKitCSSMatrix. The mutable methods
 7 can make WebKitCSSMatrix in WebGL more efficient.
 8
 9 Reviewed by NOBODY (OOPS!).
 10
 11 * css/WebKitCSSMatrix.cpp:
 12 (WebCore::WebKitCSSMatrix::WebKitCSSMatrix):
 13 (WebCore::WebKitCSSMatrix::toArray):
 14 (WebCore::WebKitCSSMatrix::setMatrixValue):
 15 (WebCore::WebKitCSSMatrix::multipliedBy):
 16 (WebCore::WebKitCSSMatrix::inverse):
 17 (WebCore::WebKitCSSMatrix::translatedBy):
 18 (WebCore::WebKitCSSMatrix::scaledBy):
 19 (WebCore::WebKitCSSMatrix::rotate):
 20 (WebCore::WebKitCSSMatrix::rotatedBy):
 21 (WebCore::WebKitCSSMatrix::rotatedAxisAngleBy):
 22 (WebCore::WebKitCSSMatrix::skewedXBy):
 23 (WebCore::WebKitCSSMatrix::skewedYBy):
 24 * css/WebKitCSSMatrix.h:
 25 (WebCore::WebKitCSSMatrix::create):
 26 * css/WebKitCSSMatrix.idl:
 27
1282011-10-18 Sam Weinig <sam@webkit.org>
229
330 Fix the build.

Source/WebCore/css/WebKitCSSMatrix.cpp

2020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2222 * (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.
2424 */
2525
2626#include "config.h"

3232#include "CSSPropertyNames.h"
3333#include "CSSValueKeywords.h"
3434#include "ExceptionCode.h"
 35#include "Float32Array.h"
 36#include "Float64Array.h"
3537#include <wtf/MathExtras.h>
3638
3739namespace WebCore {

@@WebKitCSSMatrix::WebKitCSSMatrix(const TransformationMatrix& m)
4143{
4244}
4345
44 WebKitCSSMatrix::WebKitCSSMatrix(const String& s, ExceptionCode& ec)
 46WebKitCSSMatrix::WebKitCSSMatrix(const String& s, ExceptionCode& ec)
4547{
4648 setMatrixValue(s, ec);
4749}

@@WebKitCSSMatrix::~WebKitCSSMatrix()
5052{
5153}
5254
 55void WebKitCSSMatrix::toArray(Float32Array* array)
 56{
 57 if (!array || array->length() < 16)
 58 return;
 59
 60 array->set(0, m_matrix.m11());
 61 array->set(1, m_matrix.m12());
 62 array->set(2, m_matrix.m13());
 63 array->set(3, m_matrix.m14());
 64 array->set(4, m_matrix.m21());
 65 array->set(5, m_matrix.m22());
 66 array->set(6, m_matrix.m23());
 67 array->set(7, m_matrix.m24());
 68 array->set(8, m_matrix.m31());
 69 array->set(9, m_matrix.m32());
 70 array->set(10, m_matrix.m33());
 71 array->set(11, m_matrix.m34());
 72 array->set(12, m_matrix.m41());
 73 array->set(13, m_matrix.m42());
 74 array->set(14, m_matrix.m43());
 75 array->set(15, m_matrix.m44());
 76}
 77
 78void WebKitCSSMatrix::toArray(Float64Array* array)
 79{
 80 if (!array || array->length() < 16)
 81 return;
 82
 83 array->set(0, m_matrix.m11());
 84 array->set(1, m_matrix.m12());
 85 array->set(2, m_matrix.m13());
 86 array->set(3, m_matrix.m14());
 87 array->set(4, m_matrix.m21());
 88 array->set(5, m_matrix.m22());
 89 array->set(6, m_matrix.m23());
 90 array->set(7, m_matrix.m24());
 91 array->set(8, m_matrix.m31());
 92 array->set(9, m_matrix.m32());
 93 array->set(10, m_matrix.m33());
 94 array->set(11, m_matrix.m34());
 95 array->set(12, m_matrix.m41());
 96 array->set(13, m_matrix.m42());
 97 array->set(14, m_matrix.m43());
 98 array->set(15, m_matrix.m44());
 99}
 100
53101void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
54102{
55103 RefPtr<CSSMutableStyleDeclaration> styleDeclaration = CSSMutableStyleDeclaration::create();
56104 if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, true)) {
57  // Convert to TransformOperations. This can fail if a property
 105 // Convert to TransformOperations. This can fail if a property
58106 // requires style (i.e., param uses 'ems' or 'exs')
59107 RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
60108

@@void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
67115 ec = SYNTAX_ERR;
68116 return;
69117 }
70 
 118
71119 // Convert transform operations to a TransformationMatrix. This can fail
72120 // if a param has a percentage ('%')
73121 TransformationMatrix t;

@@void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
77125 return;
78126 }
79127 }
80 
 128
81129 // set the matrix
82130 m_matrix = t;
83131 } else if (!string.isEmpty()) // There is something there but parsing failed

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::multiply(WebKitCSSMatrix* secondMat
93141 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).multiply(secondMatrix->m_matrix));
94142}
95143
 144void WebKitCSSMatrix::multipliedBy(WebKitCSSMatrix* secondMatrix)
 145{
 146 if (!secondMatrix)
 147 return;
 148
 149 m_matrix.multiply(secondMatrix->m_matrix);
 150}
 151
96152PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::inverse(ExceptionCode& ec) const
97153{
98154 if (!m_matrix.isInvertible()) {
99155 ec = NOT_SUPPORTED_ERR;
100156 return 0;
101157 }
102 
 158
103159 return WebKitCSSMatrix::create(m_matrix.inverse());
104160}
105161

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::translate(double x, double y, doubl
114170 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).translate3d(x, y, z));
115171}
116172
 173void WebKitCSSMatrix::translatedBy(double x, double y, double z)
 174{
 175 if (isnan(x))
 176 x = 0;
 177 if (isnan(y))
 178 y = 0;
 179 if (isnan(z))
 180 z = 0;
 181
 182 m_matrix.translate3d(x, y, z);
 183}
 184
117185PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const
118186{
119187 if (isnan(scaleX))

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(double scaleX, double scaleY,
125193 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).scale3d(scaleX, scaleY, scaleZ));
126194}
127195
 196void WebKitCSSMatrix::scaledBy(double scaleX, double scaleY, double scaleZ)
 197{
 198 if (isnan(scaleX))
 199 scaleX = 1;
 200 if (isnan(scaleY))
 201 scaleY = scaleX;
 202 if (isnan(scaleZ))
 203 scaleZ = 1;
 204
 205 m_matrix.scale3d(scaleX, scaleY, scaleZ);
 206}
 207
128208PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(double rotX, double rotY, double rotZ) const
129209{
130210 if (isnan(rotX))
131211 rotX = 0;
132 
 212
133213 if (isnan(rotY) && isnan(rotZ)) {
134214 rotZ = rotX;
135215 rotX = 0;

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(double rotX, double rotY, do
143223 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(rotX, rotY, rotZ));
144224}
145225
 226void WebKitCSSMatrix::rotatedBy(double rotX, double rotY, double rotZ)
 227{
 228 if (isnan(rotX))
 229 rotX = 0;
 230
 231 if (isnan(rotY) && isnan(rotZ)) {
 232 rotZ = rotX;
 233 rotX = 0;
 234 rotY = 0;
 235 }
 236
 237 if (isnan(rotY))
 238 rotY = 0;
 239 if (isnan(rotZ))
 240 rotZ = 0;
 241 m_matrix.rotate3d(rotX, rotY, rotZ);
 242}
 243
146244PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const
147245{
148246 if (isnan(x))

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotateAxisAngle(double x, double y,
158256 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(x, y, z, angle));
159257}
160258
 259void WebKitCSSMatrix::rotatedAxisAngleBy(double x, double y, double z, double angle)
 260{
 261 if (isnan(x))
 262 x = 0;
 263 if (isnan(y))
 264 y = 0;
 265 if (isnan(z))
 266 z = 0;
 267 if (isnan(angle))
 268 angle = 0;
 269 if (!x && !y && !z)
 270 z = 1;
 271 m_matrix.rotate3d(x, y, z, angle);
 272}
 273
161274PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewX(double angle) const
162275{
163276 if (isnan(angle))

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewX(double angle) const
165278 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).skewX(angle));
166279}
167280
 281void WebKitCSSMatrix::skewedXBy(double angle)
 282{
 283 if (isnan(angle))
 284 angle = 0;
 285 m_matrix.skewX(angle);
 286}
 287
168288PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewY(double angle) const
169289{
170290 if (isnan(angle))

@@PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewY(double angle) const
172292 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).skewY(angle));
173293}
174294
 295void WebKitCSSMatrix::skewedYBy(double angle)
 296{
 297 if (isnan(angle))
 298 angle = 0;
 299 m_matrix.skewY(angle);
 300}
 301
175302String WebKitCSSMatrix::toString() const
176303{
177304 // FIXME - Need to ensure valid CSS floating point values (https://bugs.webkit.org/show_bug.cgi?id=20674)

Source/WebCore/css/WebKitCSSMatrix.h

3333
3434namespace WebCore {
3535
 36class Float32Array;
 37class Float64Array;
 38
3639class WebKitCSSMatrix : public RefCounted<WebKitCSSMatrix> {
3740public:
3841 static PassRefPtr<WebKitCSSMatrix> create(const TransformationMatrix& m)

@@public:
4346 {
4447 return adoptRef(new WebKitCSSMatrix(s, ec));
4548 }
46 
 49
 50 static PassRefPtr<WebKitCSSMatrix> create(const Float32Array& array)
 51 {
 52 return adoptRef(new WebKitCSSMatrix(array));
 53 }
 54
4755 virtual ~WebKitCSSMatrix();
4856
4957 double a() const { return m_matrix.a(); }

@@public:
93101 void setM42(double f) { m_matrix.setM42(f); }
94102 void setM43(double f) { m_matrix.setM43(f); }
95103 void setM44(double f) { m_matrix.setM44(f); }
96 
 104
 105 // Copy the matrix elements for a single precision float point array
 106 void toArray(Float32Array*);
 107 // Copy the matrix elements for a double precision float point array
 108 void toArray(Float64Array*);
 109
97110 void setMatrixValue(const String&, ExceptionCode&);
98111
99112 // The following math function return a new matrix with the

@@public:
101114
102115 // Multiply this matrix by secondMatrix, on the right (result = this * secondMatrix)
103116 PassRefPtr<WebKitCSSMatrix> multiply(WebKitCSSMatrix* secondMatrix) const;
104 
 117
 118 // Multiply itself by a secondMatrix, on the right (this = this * secondMatrix)
 119 void multipliedBy(WebKitCSSMatrix* secondMatrix);
 120
105121 // Return the inverse of this matrix. Throw an exception if the matrix is not invertible
106122 PassRefPtr<WebKitCSSMatrix> inverse(ExceptionCode&) const;
107123

@@public:
110126 // Operation is performed as though the this matrix is multiplied by a matrix with
111127 // the translation values on the left (result = translation(x,y,z) * this)
112128 PassRefPtr<WebKitCSSMatrix> translate(double x, double y, double z) const;
113 
 129
 130 // Translate itself using the passed values.
 131 // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D operations
 132 // Operation is performed as though the this matrix is multiplied by a matrix with
 133 // the translation values on the left (this = translation(x,y,z) * this)
 134 void translatedBy(double x, double y, double z);
 135
114136 // Returns this matrix scaled by the passed values.
115137 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN
116138 // makes it the same as scaleX. This allows the 3D form to used for 2D operations

@@public:
118140 // the scale values on the left (result = scale(x,y,z) * this)
119141 PassRefPtr<WebKitCSSMatrix> scale(double scaleX, double scaleY, double scaleZ) const;
120142
 143 // Scale itself using the passed values.
 144 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN
 145 // makes it the same as scaleX. This allows the 3D form to used for 2D operations
 146 // Operation is performed as though the this matrix is multiplied by a matrix with
 147 // the scale values on the left (this = scale(x,y,z) * this)
 148 void scaledBy(double scaleX, double scaleY, double scaleZ);
 149
121150 // Returns this matrix rotated by the passed values.
122151 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX).
123152 // Otherwise use a rotation value of 0 for any passed NaN.
124153 // Operation is performed as though the this matrix is multiplied by a matrix with
125154 // the rotation values on the left (result = rotation(x,y,z) * this)
126155 PassRefPtr<WebKitCSSMatrix> rotate(double rotX, double rotY, double rotZ) const;
127 
 156
 157 // Rotate itself using the passed values.
 158 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX).
 159 // Otherwise use a rotation value of 0 for any passed NaN.
 160 // Operation is performed as though the this matrix is multiplied by a matrix with
 161 // the rotation values on the left (this = rotation(x,y,z) * this)
 162 void rotatedBy(double rotX, double rotY, double rotZ);
 163
128164 // Returns this matrix rotated about the passed axis by the passed angle.
129165 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value
130166 // Operation is performed as though the this matrix is multiplied by a matrix with
131167 // the rotation values on the left (result = rotation(x,y,z,angle) * this)
132168 PassRefPtr<WebKitCSSMatrix> rotateAxisAngle(double x, double y, double z, double angle) const;
133 
 169
 170 // Rotate itself using the passed axis by the passed angle.
 171 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value
 172 // Operation is performed as though the this matrix is multiplied by a matrix with
 173 // the rotation values on the left (this = rotation(x,y,z,angle) * this)
 174 void rotatedAxisAngleBy(double x, double y, double z, double angle);
 175
134176 // Return this matrix skewed along the X axis by the passed values.
135177 // Passing a NaN will use a value of 0.
136178 // Operation is performed as though the this matrix is multiplied by a matrix with
137179 // the skew values on the left (result = skewX(angle) * this)
138180 PassRefPtr<WebKitCSSMatrix> skewX(double angle) const;
139181
 182 // Skew itself along the X axis using the passed values.
 183 // Passing a NaN will use a value of 0.
 184 // Operation is performed as though the this matrix is multiplied by a matrix with
 185 // the skew values on the left (this = skewX(angle) * this)
 186 void skewedXBy(double angle);
 187
140188 // Return this matrix skewed along the Y axis by the passed values.
141189 // Passing a NaN will use a value of 0.
142190 // Operation is performed as though the this matrix is multiplied by a matrix with
143191 // the skew values on the left (result = skewY(angle) * this)
144192 PassRefPtr<WebKitCSSMatrix> skewY(double angle) const;
145193
 194 // Skew itself along the Y axis using the passed values.
 195 // Passing a NaN will use a value of 0.
 196 // Operation is performed as though the this matrix is multiplied by a matrix with
 197 // the skew values on the left (this = skewY(angle) * this)
 198 void skewedYBy(double angle);
 199
146200 const TransformationMatrix& transform() const { return m_matrix; }
147201
148202 String toString() const;

@@public:
150204protected:
151205 WebKitCSSMatrix(const TransformationMatrix&);
152206 WebKitCSSMatrix(const String&, ExceptionCode&);
 207 WebKitCSSMatrix(const Float32Array&);
153208
154209 TransformationMatrix m_matrix;
155210};

Source/WebCore/css/WebKitCSSMatrix.idl

@@module css {
5959 attribute double m43;
6060 attribute double m44;
6161
 62 // Copy the matrix elements for a single precision float point array
 63 void toArray(in Float32Array array);
 64 // Copy the matrix elements for a double precision float point array
 65 void toArray(in Float64Array array);
 66
6267 void setMatrixValue(in [Optional=CallWithDefaultValue] DOMString string) raises (DOMException);
6368
6469 // Multiply this matrix by secondMatrix, on the right (result = this * secondMatrix)
6570 [Immutable] WebKitCSSMatrix multiply(in [Optional=CallWithDefaultValue] WebKitCSSMatrix secondMatrix);
66 
 71
 72 // Multiply itself by a secondMatrix, on the right (this = this * secondMatrix)
 73 void multipliedBy(in [Optional=CallWithDefaultValue] WebKitCSSMatrix secondMatrix);
 74
6775 // Return the inverse of this matrix. Throw an exception if the matrix is not invertible
6876 [Immutable] WebKitCSSMatrix inverse() raises (DOMException);
6977

@@module css {
7280 [Immutable] WebKitCSSMatrix translate(in [Optional=CallWithDefaultValue] double x,
7381 in [Optional=CallWithDefaultValue] double y,
7482 in [Optional=CallWithDefaultValue] double z);
75 
 83
 84 // Translate itself using the passed values.
 85 // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D operations
 86 void translatedBy(in [Optional=CallWithDefaultValue] double x,
 87 in [Optional=CallWithDefaultValue] double y,
 88 in [Optional=CallWithDefaultValue] double z);
 89
 90
7691 // Returns this matrix scaled by the passed values.
7792 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN
7893 // makes it the same as scaleX. This allows the 3D form to used for 2D operations
7994 [Immutable] WebKitCSSMatrix scale(in [Optional=CallWithDefaultValue] double scaleX,
8095 in [Optional=CallWithDefaultValue] double scaleY,
8196 in [Optional=CallWithDefaultValue] double scaleZ);
82 
 97
 98 // Scale itself using the passed values.
 99 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN
 100 // makes it the same as scaleX. This allows the 3D form to used for 2D operations
 101 void scaledBy(in [Optional=CallWithDefaultValue] double scaleX,
 102 in [Optional=CallWithDefaultValue] double scaleY,
 103 in [Optional=CallWithDefaultValue] double scaleZ);
 104
83105 // Returns this matrix rotated by the passed values.
84106 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX).
85107 // Otherwise use a rotation value of 0 for any passed NaN.
86108 [Immutable] WebKitCSSMatrix rotate(in [Optional=CallWithDefaultValue] double rotX,
87109 in [Optional=CallWithDefaultValue] double rotY,
88110 in [Optional=CallWithDefaultValue] double rotZ);
89 
 111
 112 // Rotate itself using the passed values.
 113 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX).
 114 // Otherwise use a rotation value of 0 for any passed NaN.
 115 void rotatedBy(in [Optional=CallWithDefaultValue] double rotX,
 116 in [Optional=CallWithDefaultValue] double rotY,
 117 in [Optional=CallWithDefaultValue] double rotZ);
 118
90119 // Returns this matrix rotated about the passed axis by the passed angle.
91120 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value
92121 // of (0,0,1).

@@module css {
94123 in [Optional=CallWithDefaultValue] double y,
95124 in [Optional=CallWithDefaultValue] double z,
96125 in [Optional=CallWithDefaultValue] double angle);
 126 // Rotate itself using the passed axis by the passed angle.
 127 void rotatedAxisAngleBy(in [Optional=CallWithDefaultValue] double x,
 128 in [Optional=CallWithDefaultValue] double y,
 129 in [Optional=CallWithDefaultValue] double z,
 130 in [Optional=CallWithDefaultValue] double angle);
97131
98132 // Returns this matrix skewed along the X axis by the passed values.
99133 // Passing a NaN will use a value of 0.
100134 [Immutable] WebKitCSSMatrix skewX(in [Optional=CallWithDefaultValue] double angle);
101135
 136 // Skew itself along the X axis using the passed values.
 137 // Passing a NaN will use a value of 0.
 138 void skewedXBy(in [Optional=CallWithDefaultValue] double angle);
 139
102140 // Returns this matrix skewed along the Y axis by the passed values.
103141 // Passing a NaN will use a value of 0.
104142 [Immutable] WebKitCSSMatrix skewY(in [Optional=CallWithDefaultValue] double angle);
105143
 144 // Skew itself along the Y axis using the passed values.
 145 // Passing a NaN will use a value of 0.
 146 void skewedYBy(in [Optional=CallWithDefaultValue] double angle);
 147
106148 [DontEnum] DOMString toString();
107149 };
108150