| Index: Source/core/rendering/style/BorderEdge.cpp
|
| diff --git a/Source/core/rendering/style/BorderEdge.cpp b/Source/core/rendering/style/BorderEdge.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b95fcfc9a61f0f18e7a7adc6ae50825f269c1739
|
| --- /dev/null
|
| +++ b/Source/core/rendering/style/BorderEdge.cpp
|
| @@ -0,0 +1,84 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "core/rendering/style/BorderEdge.h"
|
| +
|
| +namespace blink {
|
| +
|
| +BorderEdge::BorderEdge(int edgeWidth, const Color& edgeColor, EBorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent)
|
| + : width(edgeWidth)
|
| + , color(edgeColor)
|
| + , style(edgeStyle)
|
| + , isTransparent(edgeIsTransparent)
|
| + , isPresent(edgeIsPresent)
|
| +{
|
| + if (style == DOUBLE && edgeWidth < 3)
|
| + style = SOLID;
|
| +}
|
| +
|
| +BorderEdge::BorderEdge()
|
| + : width(0)
|
| + , style(BHIDDEN)
|
| + , isTransparent(false)
|
| + , isPresent(false)
|
| +{
|
| +}
|
| +
|
| +bool BorderEdge::hasVisibleColorAndStyle() const
|
| +{
|
| + return style > BHIDDEN && !isTransparent;
|
| +}
|
| +
|
| +bool BorderEdge::shouldRender() const { return isPresent && width && hasVisibleColorAndStyle(); }
|
| +bool BorderEdge::presentButInvisible() const { return usedWidth() && !hasVisibleColorAndStyle(); }
|
| +bool BorderEdge::obscuresBackgroundEdge(float scale) const
|
| +{
|
| + if (!isPresent || isTransparent || (width * scale) < 2 || color.hasAlpha() || style == BHIDDEN)
|
| + return false;
|
| +
|
| + if (style == DOTTED || style == DASHED)
|
| + return false;
|
| +
|
| + if (style == DOUBLE)
|
| + return width >= 5 * scale; // The outer band needs to be >= 2px wide at unit scale.
|
| +
|
| + return true;
|
| +}
|
| +bool BorderEdge::obscuresBackground() const
|
| +{
|
| + if (!isPresent || isTransparent || color.hasAlpha() || style == BHIDDEN)
|
| + return false;
|
| +
|
| + if (style == DOTTED || style == DASHED || style == DOUBLE)
|
| + return false;
|
| +
|
| + return true;
|
| +}
|
| +
|
| +int BorderEdge::usedWidth() const
|
| +{
|
| + return isPresent ? width : 0;
|
| +}
|
| +
|
| +void BorderEdge::getDoubleBorderStripeWidths(int& outerWidth, int& innerWidth) const
|
| +{
|
| + int fullWidth = usedWidth();
|
| + outerWidth = fullWidth / 3;
|
| + innerWidth = fullWidth * 2 / 3;
|
| +
|
| + // We need certain integer rounding results
|
| + if (fullWidth % 3 == 2)
|
| + outerWidth += 1;
|
| +
|
| + if (fullWidth % 3 == 1)
|
| + innerWidth += 1;
|
| +}
|
| +
|
| +bool BorderEdge::sharesColorWith(const BorderEdge& other) const
|
| +{
|
| + return color == other.color;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|