New issue
Advanced search Search tips

Issue 632096 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Add pretty printers for geometry types

Project Member Reported by pdr@chromium.org, Jul 27 2016

Issue description

It's a drag on development to have to type things like this:
LOG(INFO) << "rect: " << rect.x().toFloat() << ", " << rect.y().toFloat() ...

We should add pretty printers to make this easier. This will slightly increase the binary size so we should keep that in mind, though it will likely be negligible.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 20 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb

commit bdceea3ea3872c9188c48c0a6e71d9a52ff92feb
Author: pdr <pdr@chromium.org>
Date: Sat Aug 20 19:19:39 2016

Add platform/geometry pretty printers for logging and testing

This patch switches from a test-only GeometryPrinters and debug-only
toString() to a common pretty printer format for logging and testing.

For example, to print the value of a LayoutRect:
    LayoutRect overflowRect(1, 2, 3, 4);
    LOG(INFO) << "overflow: " << overflowRect.toString();
Which prints:
    overflow: "1,2 3x4"

In tests, gtests will automatically call the PrintTo functions. In
debuggers, toString() should work as expected.

Minor changes:
1) Switched floating point precision to use "%lg" which prints up to
6 significant figures, and fewer if the value is an integer.
2) Added special-cases to catch LayoutUnit's min/max/nearly{Min,Max}.

BUG= 632096 

Review-Url: https://codereview.chromium.org/2191233002
Cr-Commit-Position: refs/heads/master@{#413347}

[add] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/LayoutUnit.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/LayoutUnit.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/blink_platform.gypi
[add] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatBox.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatBox.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatBoxTest.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatPoint.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatPoint.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatPoint3D.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatPoint3D.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatQuad.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatQuad.h
[add] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatQuadTest.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatRect.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatRect.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatRoundedRect.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatRoundedRect.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatRoundedRectTest.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatSize.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/FloatSize.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntPoint.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntPoint.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntRect.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntRect.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntRectTest.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntSize.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/IntSize.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutPoint.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutPoint.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutRect.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutRect.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutRectTest.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutSize.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/geometry/LayoutSize.h
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/testing/GeometryPrinters.cpp
[modify] https://crrev.com/bdceea3ea3872c9188c48c0a6e71d9a52ff92feb/third_party/WebKit/Source/platform/testing/GeometryPrinters.h

Project Member

Comment 2 by bugdroid1@chromium.org, Aug 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/54bd1a11aa538122321db5481881cf8603e9bf2e

commit 54bd1a11aa538122321db5481881cf8603e9bf2e
Author: pdr <pdr@chromium.org>
Date: Mon Aug 22 19:27:22 2016

Add platform/transforms pretty printers for logging and testing

This patch switches from a test-only TransformPrinters to a common
pretty printer format for logging and testing in debug and release.

For example, to print the value of an AffineTransform:
    AffineTransform transform = AffineTransform::translation(3, 4);
    LOG(INFO) << "transform: " << translation.toString();
Which prints:
    transform: "translation(3,4)"

In tests, gtests will automatically call the PrintTo functions. For
example:
    AffineTransform translation = AffineTransform::translation(7, 9);
    AffineTransform rotation;
    rotation.rotate(180);
    EXPECT_EQ(translation, rotation);
Will fail with:
    Actual: "translation(0,0), scale(1,1), angle(3.14159rad), remainder(1,0,0,1)"
    Expected: "translation(7,9)"
    [  FAILED  ] AffineTransformTest.NotEqual (0 ms)

In debuggers, toString() should work as expected. There is also an
optional argument to print the transforms in row-major order.

BUG= 632096 

Review-Url: https://codereview.chromium.org/2265453003
Cr-Commit-Position: refs/heads/master@{#413504}

[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/blink_platform.gypi
[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/testing/TransformPrinters.cpp
[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/transforms/AffineTransform.cpp
[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/transforms/AffineTransform.h
[add] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/transforms/AffineTransformTest.cpp
[delete] https://crrev.com/fb88be5ed924fea212e66f632daabcf15ab658d9/third_party/WebKit/Source/platform/transforms/TransformTestHelper.h
[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/transforms/TransformationMatrix.h
[modify] https://crrev.com/54bd1a11aa538122321db5481881cf8603e9bf2e/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp

Project Member

Comment 4 by bugdroid1@chromium.org, Aug 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/543079b35d7fedda30a4bc17c286038a71c81307

commit 543079b35d7fedda30a4bc17c286038a71c81307
Author: pdr <pdr@chromium.org>
Date: Mon Aug 22 23:11:22 2016

Add Double{Size, Point, Rect} pretty printers for logging and testing

This patch unifies the pretty printers for DoubleSize, DoublePoint,
and DoubleRect with the approach used for LayoutRect, FloatRect, etc.

For example, to print the value of a DoubleRect:
    DoubleRect rect(1, 2, 3, 4);
    LOG(INFO) << "rect: " << rect;
Which prints:
    rect: "1,2 3x4"

BUG= 632096 

Review-Url: https://codereview.chromium.org/2195903002
Cr-Commit-Position: refs/heads/master@{#413569}

[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoublePoint.cpp
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoublePoint.h
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoubleRect.cpp
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoubleRect.h
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoubleRectTest.cpp
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoubleSize.cpp
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/geometry/DoubleSize.h
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/testing/GeometryPrinters.cpp
[modify] https://crrev.com/543079b35d7fedda30a4bc17c286038a71c81307/third_party/WebKit/Source/platform/testing/GeometryPrinters.h

Comment 5 by pdr@chromium.org, Aug 26 2016

Status: Fixed (was: Assigned)
We investigated adding operator<< but it sadly regressed binary size: https://codereview.chromium.org/2267183003

Marking as fixed
Project Member

Comment 6 by bugdroid1@chromium.org, Nov 11 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fc7473554b53ff5aa7b54fe2b51298c2bc43cbb6

commit fc7473554b53ff5aa7b54fe2b51298c2bc43cbb6
Author: pdr <pdr@chromium.org>
Date: Fri Nov 11 00:22:02 2016

Add CullRect::toString

Hit this with szager and it was the last straw. Lets add a toString
helper to make CullRect more debuggable. The implementation just
forwards to the IntRect toString.

BUG= 632096 

Review-Url: https://codereview.chromium.org/2496573003
Cr-Commit-Position: refs/heads/master@{#431401}

[modify] https://crrev.com/fc7473554b53ff5aa7b54fe2b51298c2bc43cbb6/third_party/WebKit/Source/platform/graphics/paint/CullRect.h

Sign in to add a comment