- Revision
- 201401
- Author
- cdu...@apple.com
- Date
- 2016-05-25 14:13:22 -0700 (Wed, 25 May 2016)
Log Message
Simplify and inline minimumValueForLength()
https://bugs.webkit.org/show_bug.cgi?id=158084
Reviewed by Zalan Bujtas.
Simplify and inline minimumValueForLength(). Based on iOS PLT profiles,
we spend up to 0.7% of CPU time during page loads in this function.
The roundPercentages parameter has been dropped because it was false
for all call sites.
* css/LengthFunctions.cpp:
(WebCore::minimumIntValueForLength): Deleted.
(WebCore::minimumValueForLength): Deleted.
* css/LengthFunctions.h:
(WebCore::minimumValueForLength):
(WebCore::minimumIntValueForLength):
* rendering/RenderBoxModelObject.cpp:
(WebCore::resolveEdgeRelativeLength):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
* rendering/RenderElement.h:
(WebCore::RenderElement::minimumValueForLength):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (201400 => 201401)
--- trunk/Source/WebCore/ChangeLog 2016-05-25 21:02:11 UTC (rev 201400)
+++ trunk/Source/WebCore/ChangeLog 2016-05-25 21:13:22 UTC (rev 201401)
@@ -1,3 +1,28 @@
+2016-05-25 Chris Dumez <cdu...@apple.com>
+
+ Simplify and inline minimumValueForLength()
+ https://bugs.webkit.org/show_bug.cgi?id=158084
+
+ Reviewed by Zalan Bujtas.
+
+ Simplify and inline minimumValueForLength(). Based on iOS PLT profiles,
+ we spend up to 0.7% of CPU time during page loads in this function.
+
+ The roundPercentages parameter has been dropped because it was false
+ for all call sites.
+
+ * css/LengthFunctions.cpp:
+ (WebCore::minimumIntValueForLength): Deleted.
+ (WebCore::minimumValueForLength): Deleted.
+ * css/LengthFunctions.h:
+ (WebCore::minimumValueForLength):
+ (WebCore::minimumIntValueForLength):
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::resolveEdgeRelativeLength):
+ (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+ * rendering/RenderElement.h:
+ (WebCore::RenderElement::minimumValueForLength):
+
2016-05-25 Manuel Rego Casasnovas <r...@igalia.com>
[css-grid] Update <fixed-size> syntax
Modified: trunk/Source/WebCore/css/LengthFunctions.cpp (201400 => 201401)
--- trunk/Source/WebCore/css/LengthFunctions.cpp 2016-05-25 21:02:11 UTC (rev 201400)
+++ trunk/Source/WebCore/css/LengthFunctions.cpp 2016-05-25 21:13:22 UTC (rev 201401)
@@ -25,50 +25,15 @@
#include "LengthFunctions.h"
#include "FloatSize.h"
-#include "LayoutUnit.h"
#include "LengthSize.h"
namespace WebCore {
-int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages)
-{
- return static_cast<int>(minimumValueForLength(length, maximumValue, roundPercentages));
-}
-
int intValueForLength(const Length& length, LayoutUnit maximumValue)
{
return static_cast<int>(valueForLength(length, maximumValue));
}
-LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages)
-{
- switch (length.type()) {
- case Fixed:
- return length.value();
- case Percent:
- if (roundPercentages)
- return LayoutUnit(round(maximumValue * length.percent() / 100.0f));
- // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack.
- return LayoutUnit(static_cast<float>(maximumValue * length.percent() / 100.0f));
- case Calculated:
- return length.nonNanCalculatedValue(maximumValue);
- case FillAvailable:
- case Auto:
- return 0;
- case Relative:
- case Intrinsic:
- case MinIntrinsic:
- case MinContent:
- case MaxContent:
- case FitContent:
- case Undefined:
- ASSERT_NOT_REACHED();
- return 0;
- }
- ASSERT_NOT_REACHED();
- return 0;
-}
-
LayoutUnit valueForLength(const Length& length, LayoutUnit maximumValue)
{
switch (length.type()) {
Modified: trunk/Source/WebCore/css/LengthFunctions.h (201400 => 201401)
--- trunk/Source/WebCore/css/LengthFunctions.h 2016-05-25 21:02:11 UTC (rev 201400)
+++ trunk/Source/WebCore/css/LengthFunctions.h 2016-05-25 21:13:22 UTC (rev 201401)
@@ -24,6 +24,9 @@
#ifndef LengthFunctions_h
#define LengthFunctions_h
+#include "LayoutUnit.h"
+#include "Length.h"
+
namespace WebCore {
class FloatSize;
@@ -32,14 +35,45 @@
struct Length;
struct LengthSize;
-int minimumIntValueForLength(const Length&, LayoutUnit maximumValue, bool roundPercentages = false);
+int minimumIntValueForLength(const Length&, LayoutUnit maximumValue);
int intValueForLength(const Length&, LayoutUnit maximumValue);
-LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue, bool roundPercentages = false);
+LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue);
WEBCORE_EXPORT LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue);
float floatValueForLength(const Length&, LayoutUnit maximumValue);
WEBCORE_EXPORT float floatValueForLength(const Length&, float maximumValue);
FloatSize floatSizeForLengthSize(const LengthSize&, const FloatSize&);
+inline LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue)
+{
+ switch (length.type()) {
+ case Fixed:
+ return length.value();
+ case Percent:
+ // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack.
+ return LayoutUnit(static_cast<float>(maximumValue * length.percent() / 100.0f));
+ case Calculated:
+ return length.nonNanCalculatedValue(maximumValue);
+ case FillAvailable:
+ case Auto:
+ return 0;
+ case Relative:
+ case Intrinsic:
+ case MinIntrinsic:
+ case MinContent:
+ case MaxContent:
+ case FitContent:
+ case Undefined:
+ break;
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+inline int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue)
+{
+ return static_cast<int>(minimumValueForLength(length, maximumValue));
+}
+
} // namespace WebCore
#endif // LengthFunctions_h
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (201400 => 201401)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2016-05-25 21:02:11 UTC (rev 201400)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2016-05-25 21:13:22 UTC (rev 201401)
@@ -1051,7 +1051,7 @@
static LayoutUnit resolveEdgeRelativeLength(const Length& length, Edge edge, LayoutUnit availableSpace, const LayoutSize& areaSize, const LayoutSize& tileSize)
{
- LayoutUnit result = minimumValueForLength(length, availableSpace, false);
+ LayoutUnit result = minimumValueForLength(length, availableSpace);
if (edge == Edge::Right)
return areaSize.width() - tileSize.width() - result;
@@ -1192,7 +1192,7 @@
LayoutUnit space = getSpace(positioningAreaSize.width(), tileSize.width());
if (space >= 0) {
LayoutUnit actualWidth = tileSize.width() + space;
- computedXPosition = minimumValueForLength(Length(), availableWidth, false);
+ computedXPosition = minimumValueForLength(Length(), availableWidth);
spaceSize.setWidth(space);
spaceSize.setHeight(0);
phase.setWidth(actualWidth ? actualWidth - fmodf((computedXPosition + left), actualWidth) : 0);
@@ -1218,7 +1218,7 @@
if (space >= 0) {
LayoutUnit actualHeight = tileSize.height() + space;
- computedYPosition = minimumValueForLength(Length(), availableHeight, false);
+ computedYPosition = minimumValueForLength(Length(), availableHeight);
spaceSize.setHeight(space);
phase.setHeight(actualHeight ? actualHeight - fmodf((computedYPosition + top), actualHeight) : 0);
} else
Modified: trunk/Source/WebCore/rendering/RenderElement.h (201400 => 201401)
--- trunk/Source/WebCore/rendering/RenderElement.h 2016-05-25 21:02:11 UTC (rev 201400)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2016-05-25 21:13:22 UTC (rev 201401)
@@ -241,7 +241,7 @@
void propagateStyleToAnonymousChildren(StylePropagationType);
LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue) const;
- LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue, bool roundPercentages = false) const;
+ LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue) const;
void setFirstChild(RenderObject* child) { m_firstChild = child; }
void setLastChild(RenderObject* child) { m_lastChild = child; }
@@ -371,9 +371,9 @@
return WebCore::valueForLength(length, maximumValue);
}
-inline LayoutUnit RenderElement::minimumValueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages) const
+inline LayoutUnit RenderElement::minimumValueForLength(const Length& length, LayoutUnit maximumValue) const
{
- return WebCore::minimumValueForLength(length, maximumValue, roundPercentages);
+ return WebCore::minimumValueForLength(length, maximumValue);
}
inline bool RenderElement::isRenderLayerModelObject() const