Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
FractionalLayoutUnit minor math bugs
https://bugs.webkit.org/show_bug.cgi?id=86065

Reviewed by Levi Weintraub.

Implement a consistent set of subject modifying operators, to ensure
operations that need to be in float are performed in float.

Scale FractionalLayoutSize in FractionalLayoutUnits instead of intergers.

No new functionality. No new tests.

* platform/FractionalLayoutUnit.h:
(WebCore::operator-=):
(WebCore::operator*=):
(WebCore::operator/=):
* platform/graphics/FractionalLayoutSize.h:
(WebCore::FractionalLayoutSize::scale):


Canonical link: https://commits.webkit.org/110628@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Allan Sandfeld Jensen committed Jul 31, 2012
1 parent e246cdc commit fe19e7e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
2012-07-31 Allan Sandfeld Jensen <allan.jensen@nokia.com>

FractionalLayoutUnit minor math bugs
https://bugs.webkit.org/show_bug.cgi?id=86065

Reviewed by Levi Weintraub.

Implement a consistent set of subject modifying operators, to ensure
operations that need to be in float are performed in float.

Scale FractionalLayoutSize in FractionalLayoutUnits instead of intergers.

No new functionality. No new tests.

* platform/FractionalLayoutUnit.h:
(WebCore::operator-=):
(WebCore::operator*=):
(WebCore::operator/=):
* platform/graphics/FractionalLayoutSize.h:
(WebCore::FractionalLayoutSize::scale):

2012-07-31 Joshua Netterfield <jnetterfield@rim.com>

[BlackBerry] Enable CSS Filter Effects
Expand Down
34 changes: 33 additions & 1 deletion Source/WebCore/platform/FractionalLayoutUnit.h
Expand Up @@ -592,24 +592,56 @@ inline FractionalLayoutUnit& operator-=(FractionalLayoutUnit& a, const Fractiona
return a;
}

inline FractionalLayoutUnit& operator-=(FractionalLayoutUnit& a, float b)
{
a = a - b;
return a;
}

inline float& operator-=(float& a, const FractionalLayoutUnit& b)
{
a = a - b;
return a;
}

inline FractionalLayoutUnit& operator*=(FractionalLayoutUnit& a, int b)
inline FractionalLayoutUnit& operator*=(FractionalLayoutUnit& a, const FractionalLayoutUnit& b)
{
a = a * b;
return a;
}
// operator*=(FractionalLayoutUnit& a, int b) is supported by the operator above plus FractionalLayoutUnit(int).

inline FractionalLayoutUnit& operator*=(FractionalLayoutUnit& a, float b)
{
a = a * b;
return a;
}

inline float& operator*=(float& a, const FractionalLayoutUnit& b)
{
a = a * b;
return a;
}

inline FractionalLayoutUnit& operator/=(FractionalLayoutUnit& a, const FractionalLayoutUnit& b)
{
a = a / b;
return a;
}
// operator/=(FractionalLayoutUnit& a, int b) is supported by the operator above plus FractionalLayoutUnit(int).

inline FractionalLayoutUnit& operator/=(FractionalLayoutUnit& a, float b)
{
a = a / b;
return a;
}

inline float& operator/=(float& a, const FractionalLayoutUnit& b)
{
a = a / b;
return a;
}

inline int snapSizeToPixel(FractionalLayoutUnit size, FractionalLayoutUnit location)
{
return (location + size).round() - location.round();
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/FractionalLayoutSize.h
Expand Up @@ -74,8 +74,8 @@ class FractionalLayoutSize {

void scale(float scale)
{
m_width = static_cast<int>(static_cast<float>(m_width) * scale);
m_height = static_cast<int>(static_cast<float>(m_height) * scale);
m_width *= scale;
m_height *= scale;
}

FractionalLayoutSize expandedTo(const FractionalLayoutSize& other) const
Expand Down

0 comments on commit fe19e7e

Please sign in to comment.