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

Unified Diff: Source/core/paint/DetailsMarkerPainter.cpp

Issue 596563003: Move painting code from RenderDetailsMarker into DetailsMarkerPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge 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/paint/DetailsMarkerPainter.h ('k') | Source/core/rendering/RenderDetailsMarker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/DetailsMarkerPainter.cpp
diff --git a/Source/core/paint/DetailsMarkerPainter.cpp b/Source/core/paint/DetailsMarkerPainter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5f89280cc0b89fcf809b6017cd9ec972c2ed5682
--- /dev/null
+++ b/Source/core/paint/DetailsMarkerPainter.cpp
@@ -0,0 +1,93 @@
+// 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/paint/DetailsMarkerPainter.h"
+
+#include "core/paint/BlockPainter.h"
+#include "core/rendering/PaintInfo.h"
+#include "core/rendering/RenderDetailsMarker.h"
+#include "platform/geometry/LayoutPoint.h"
+#include "platform/graphics/Path.h"
+
+namespace blink {
+
+void DetailsMarkerPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ if (paintInfo.phase != PaintPhaseForeground || m_renderDetailsMarker.style()->visibility() != VISIBLE) {
+ BlockPainter(m_renderDetailsMarker).paint(paintInfo, paintOffset);
+ return;
+ }
+
+ LayoutPoint boxOrigin(paintOffset + m_renderDetailsMarker.location());
+ LayoutRect overflowRect(m_renderDetailsMarker.visualOverflowRect());
+ overflowRect.moveBy(boxOrigin);
+
+ if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect)))
+ return;
+
+ const Color color(m_renderDetailsMarker.resolveColor(CSSPropertyColor));
+ paintInfo.context->setStrokeColor(color);
+ paintInfo.context->setStrokeStyle(SolidStroke);
+ paintInfo.context->setStrokeThickness(1.0f);
+ paintInfo.context->setFillColor(color);
+
+ boxOrigin.move(m_renderDetailsMarker.borderLeft() + m_renderDetailsMarker.paddingLeft(), m_renderDetailsMarker.borderTop() + m_renderDetailsMarker.paddingTop());
+ paintInfo.context->fillPath(getPath(boxOrigin));
+}
+
+static Path createPath(const FloatPoint* path)
+{
+ Path result;
+ result.moveTo(FloatPoint(path[0].x(), path[0].y()));
+ for (int i = 1; i < 4; ++i)
+ result.addLineTo(FloatPoint(path[i].x(), path[i].y()));
+ return result;
+}
+
+static Path createDownArrowPath()
+{
+ FloatPoint points[4] = { FloatPoint(0.0f, 0.07f), FloatPoint(0.5f, 0.93f), FloatPoint(1.0f, 0.07f), FloatPoint(0.0f, 0.07f) };
+ return createPath(points);
+}
+
+static Path createUpArrowPath()
+{
+ FloatPoint points[4] = { FloatPoint(0.0f, 0.93f), FloatPoint(0.5f, 0.07f), FloatPoint(1.0f, 0.93f), FloatPoint(0.0f, 0.93f) };
+ return createPath(points);
+}
+
+static Path createLeftArrowPath()
+{
+ FloatPoint points[4] = { FloatPoint(1.0f, 0.0f), FloatPoint(0.14f, 0.5f), FloatPoint(1.0f, 1.0f), FloatPoint(1.0f, 0.0f) };
+ return createPath(points);
+}
+
+static Path createRightArrowPath()
+{
+ FloatPoint points[4] = { FloatPoint(0.0f, 0.0f), FloatPoint(0.86f, 0.5f), FloatPoint(0.0f, 1.0f), FloatPoint(0.0f, 0.0f) };
+ return createPath(points);
+}
+
+Path DetailsMarkerPainter::getCanonicalPath() const
+{
+ switch (m_renderDetailsMarker.orientation()) {
+ case RenderDetailsMarker::Left: return createLeftArrowPath();
+ case RenderDetailsMarker::Right: return createRightArrowPath();
+ case RenderDetailsMarker::Up: return createUpArrowPath();
+ case RenderDetailsMarker::Down: return createDownArrowPath();
+ }
+
+ return Path();
+}
+
+Path DetailsMarkerPainter::getPath(const LayoutPoint& origin) const
+{
+ Path result = getCanonicalPath();
+ result.transform(AffineTransform().scale(m_renderDetailsMarker.contentWidth().toFloat(), m_renderDetailsMarker.contentHeight().toFloat()));
+ result.translate(FloatSize(origin.x().toFloat(), origin.y().toFloat()));
+ return result;
+}
+
+} // namespace paint
« no previous file with comments | « Source/core/paint/DetailsMarkerPainter.h ('k') | Source/core/rendering/RenderDetailsMarker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698