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

Unified Diff: Source/core/rendering/TextPainter.h

Issue 538663002: Move InlineTextBox::paint guts into blink::TextPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase 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/InlineTextBox.cpp ('k') | Source/core/rendering/TextPainter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/TextPainter.h
diff --git a/Source/core/rendering/TextPainter.h b/Source/core/rendering/TextPainter.h
new file mode 100644
index 0000000000000000000000000000000000000000..95bfd70513977651b31f7eabc17289cd15157ed8
--- /dev/null
+++ b/Source/core/rendering/TextPainter.h
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef TextPainter_h
+#define TextPainter_h
+
+#include "core/rendering/style/RenderStyleConstants.h"
+#include "platform/geometry/FloatPoint.h"
+#include "platform/geometry/FloatRect.h"
+#include "platform/graphics/Color.h"
+#include "wtf/text/AtomicString.h"
+
+namespace blink {
+
+class Font;
+class GraphicsContext;
+class GraphicsContextStateSaver;
+class RenderCombineText;
+class ShadowList;
+class TextRun;
+struct TextRunPaintInfo;
+
+class TextPainter {
+public:
+ struct Style;
+
+ TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint& textOrigin, const FloatRect& textBounds, bool horizontal);
+ ~TextPainter();
+
+ void setEmphasisMark(const AtomicString&, TextEmphasisPosition);
+ void setCombinedText(RenderCombineText* combinedText) { m_combinedText = combinedText; }
+
+ static void updateGraphicsContext(GraphicsContext*, const Style&, bool horizontal, GraphicsContextStateSaver&);
+
+ void paint(int startOffset, int endOffset, int length, const Style&);
+
+ struct Style {
+ Color fillColor;
+ Color strokeColor;
+ Color emphasisMarkColor;
+ float strokeWidth;
+ const ShadowList* shadow;
+
+ bool operator==(const Style& other)
+ {
+ return fillColor == other.fillColor
+ && strokeColor == other.strokeColor
+ && emphasisMarkColor == other.emphasisMarkColor
+ && strokeWidth == other.strokeWidth
+ && shadow == other.shadow;
+ }
+ bool operator!=(const Style& other) { return !(*this == other); }
+ };
+
+private:
+ void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& saver)
+ {
+ updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver);
+ }
+
+ enum PaintInternalStep { PaintText, PaintEmphasisMark };
+
+ template <PaintInternalStep step>
+ void paintInternalRun(TextRunPaintInfo&, int from, int to);
+
+ template <PaintInternalStep step>
+ void paintInternal(int startOffset, int endOffset, int truncationPoint);
+
+ void paintEmphasisMarkForCombinedText();
+
+ GraphicsContext* m_graphicsContext;
+ const Font& m_font;
+ const TextRun& m_run;
+ FloatPoint m_textOrigin;
+ FloatRect m_textBounds;
+ bool m_horizontal;
+ AtomicString m_emphasisMark;
+ int m_emphasisMarkOffset;
+ RenderCombineText* m_combinedText;
+};
+
+} // namespace blink
+
+#endif // TextPainter_h
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/TextPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698