diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/shapes/RectangleShape.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/shapes/RectangleShape.cpp')
-rw-r--r-- | Source/WebCore/rendering/shapes/RectangleShape.cpp | 138 |
1 files changed, 5 insertions, 133 deletions
diff --git a/Source/WebCore/rendering/shapes/RectangleShape.cpp b/Source/WebCore/rendering/shapes/RectangleShape.cpp index 83768cc43..f3619d6a5 100644 --- a/Source/WebCore/rendering/shapes/RectangleShape.cpp +++ b/Source/WebCore/rendering/shapes/RectangleShape.cpp @@ -12,7 +12,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -40,26 +40,6 @@ static inline float ellipseXIntercept(float y, float rx, float ry) return rx * sqrt(1 - (y * y) / (ry * ry)); } -static inline float ellipseYIntercept(float x, float rx, float ry) -{ - ASSERT(rx > 0); - return ry * sqrt(1 - (x * x) / (rx * rx)); -} - -FloatRect RectangleShape::shapePaddingBounds() const -{ - ASSERT(shapePadding() >= 0); - if (!shapePadding() || isEmpty()) - return m_bounds; - - float boundsX = x() + std::min(width() / 2, shapePadding()); - float boundsY = y() + std::min(height() / 2, shapePadding()); - float boundsWidth = std::max(0.0f, width() - shapePadding() * 2); - float boundsHeight = std::max(0.0f, height() - shapePadding() * 2); - - return FloatRect(boundsX, boundsY, boundsWidth, boundsHeight); -} - FloatRect RectangleShape::shapeMarginBounds() const { ASSERT(shapeMargin() >= 0); @@ -73,17 +53,17 @@ FloatRect RectangleShape::shapeMarginBounds() const return FloatRect(boundsX, boundsY, boundsWidth, boundsHeight); } -void RectangleShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const +LineSegment RectangleShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const { const FloatRect& bounds = shapeMarginBounds(); if (bounds.isEmpty()) - return; + return LineSegment(); float y1 = logicalTop; float y2 = logicalTop + logicalHeight; if (y2 < bounds.y() || y1 >= bounds.maxY()) - return; + return LineSegment(); float x1 = bounds.x(); float x2 = bounds.maxX(); @@ -105,115 +85,7 @@ void RectangleShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logi } } - result.append(LineSegment(x1, x2)); -} - -void RectangleShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const -{ - const FloatRect& bounds = shapePaddingBounds(); - if (bounds.isEmpty()) - return; - - float y1 = logicalTop; - float y2 = logicalTop + logicalHeight; - - if (y1 < bounds.y() || y2 > bounds.maxY()) - return; - - float x1 = bounds.x(); - float x2 = bounds.maxX(); - - float paddingRadiusX = std::max(0.0f, rx() - shapePadding()); - float paddingRadiusY = std::max(0.0f, ry() - shapePadding()); - - if (paddingRadiusX > 0) { - bool y1InterceptsCorner = y1 < bounds.y() + paddingRadiusY; - bool y2InterceptsCorner = y2 > bounds.maxY() - paddingRadiusY; - float xi = 0; - - if (y1InterceptsCorner && y2InterceptsCorner) { - if (y1 < bounds.height() + 2 * bounds.y() - y2) { - float yi = y1 - bounds.y() - paddingRadiusY; - xi = ellipseXIntercept(yi, paddingRadiusX, paddingRadiusY); - } else { - float yi = y2 - (bounds.maxY() - paddingRadiusY); - xi = ellipseXIntercept(yi, paddingRadiusX, paddingRadiusY); - } - } else if (y1InterceptsCorner) { - float yi = y1 - bounds.y() - paddingRadiusY; - xi = ellipseXIntercept(yi, paddingRadiusX, paddingRadiusY); - } else if (y2InterceptsCorner) { - float yi = y2 - (bounds.maxY() - paddingRadiusY); - xi = ellipseXIntercept(yi, paddingRadiusX, paddingRadiusY); - } - - if (y1InterceptsCorner || y2InterceptsCorner) { - x1 = bounds.x() + paddingRadiusX - xi; - x2 = bounds.maxX() - paddingRadiusX + xi; - } - } - - result.append(LineSegment(x1, x2)); -} - -static FloatPoint cornerInterceptForWidth(float width, float widthAtIntercept, float rx, float ry) -{ - float xi = (width - widthAtIntercept) / 2; - float yi = ry - ellipseYIntercept(rx - xi, rx, ry); - return FloatPoint(xi, yi); -} - -bool RectangleShape::firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const FloatSize& minLogicalIntervalSize, LayoutUnit& result) const -{ - float minIntervalTop = minLogicalIntervalTop; - float minIntervalHeight = minLogicalIntervalSize.height(); - float minIntervalWidth = minLogicalIntervalSize.width(); - - const FloatRect& bounds = shapePaddingBounds(); - if (bounds.isEmpty() || minIntervalWidth > bounds.width()) - return false; - - float minY = std::max(bounds.y(), minIntervalTop); - float maxY = minY + minIntervalHeight; - - if (maxY > bounds.maxY()) - return false; - - float paddingRadiusX = std::max(0.0f, rx() - shapePadding()); - float paddingRadiusY = std::max(0.0f, ry() - shapePadding()); - - bool intervalOverlapsMinCorner = minY < bounds.y() + paddingRadiusY; - bool intervalOverlapsMaxCorner = maxY > bounds.maxY() - paddingRadiusY; - - if (!intervalOverlapsMinCorner && !intervalOverlapsMaxCorner) { - result = ceiledLayoutUnit(minY); - return true; - } - - float centerY = bounds.y() + bounds.height() / 2; - bool minCornerDefinesX = fabs(centerY - minY) > fabs(centerY - maxY); - bool intervalFitsWithinCorners = minIntervalWidth + 2 * paddingRadiusX <= bounds.width(); - FloatPoint cornerIntercept = cornerInterceptForWidth(bounds.width(), minIntervalWidth, paddingRadiusX, paddingRadiusY); - - if (intervalOverlapsMinCorner && (!intervalOverlapsMaxCorner || minCornerDefinesX)) { - if (intervalFitsWithinCorners || bounds.y() + cornerIntercept.y() < minY) { - result = ceiledLayoutUnit(minY); - return true; - } - if (minIntervalHeight < bounds.height() - (2 * cornerIntercept.y())) { - result = ceiledLayoutUnit(bounds.y() + cornerIntercept.y()); - return true; - } - } - - if (intervalOverlapsMaxCorner && (!intervalOverlapsMinCorner || !minCornerDefinesX)) { - if (intervalFitsWithinCorners || minY <= bounds.maxY() - cornerIntercept.y() - minIntervalHeight) { - result = ceiledLayoutUnit(minY); - return true; - } - } - - return false; + return LineSegment(x1, x2); } void RectangleShape::buildDisplayPaths(DisplayPaths& paths) const |