Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Unified Diff: Source/core/rendering/style/BorderEdge.cpp

Issue 550363004: Factor painting code out of RenderBox into a new class called BoxPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/style/BorderEdge.h ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6112f7b785c72a1b2d81b77ba355099d61af477d
--- /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)
+ , isTransparent(edgeIsTransparent)
+ , isPresent(edgeIsPresent)
+ , style(edgeStyle)
+{
+ if (style == DOUBLE && edgeWidth < 3)
+ style = SOLID;
+}
+
+BorderEdge::BorderEdge()
+ : width(0)
+ , isTransparent(false)
+ , isPresent(false)
+ , style(BHIDDEN)
+{
+}
+
+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
« no previous file with comments | « Source/core/rendering/style/BorderEdge.h ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698