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

Side by Side Diff: Source/core/paint/InlineTextBoxPainter.cpp

Issue 1129793005: Replace OwnPtr with WTF::Optional for optional recorders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge with master Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/InlineTextBoxPainter.h" 6 #include "core/paint/InlineTextBoxPainter.h"
7 7
8 #include "core/dom/DocumentMarkerController.h" 8 #include "core/dom/DocumentMarkerController.h"
9 #include "core/dom/RenderedDocumentMarker.h" 9 #include "core/dom/RenderedDocumentMarker.h"
10 #include "core/editing/CompositionUnderline.h" 10 #include "core/editing/CompositionUnderline.h"
11 #include "core/editing/CompositionUnderlineRangeFilter.h" 11 #include "core/editing/CompositionUnderlineRangeFilter.h"
12 #include "core/editing/Editor.h" 12 #include "core/editing/Editor.h"
13 #include "core/editing/InputMethodController.h" 13 #include "core/editing/InputMethodController.h"
14 #include "core/frame/LocalFrame.h" 14 #include "core/frame/LocalFrame.h"
15 #include "core/layout/LayoutBlock.h" 15 #include "core/layout/LayoutBlock.h"
16 #include "core/layout/LayoutTextCombine.h" 16 #include "core/layout/LayoutTextCombine.h"
17 #include "core/layout/LayoutTheme.h" 17 #include "core/layout/LayoutTheme.h"
18 #include "core/layout/line/InlineTextBox.h" 18 #include "core/layout/line/InlineTextBox.h"
19 #include "core/paint/BoxPainter.h" 19 #include "core/paint/BoxPainter.h"
20 #include "core/paint/PaintInfo.h" 20 #include "core/paint/PaintInfo.h"
21 #include "core/paint/TextPainter.h" 21 #include "core/paint/TextPainter.h"
22 #include "platform/graphics/paint/DrawingRecorder.h" 22 #include "platform/graphics/paint/DrawingRecorder.h"
23 #include "wtf/Optional.h"
23 24
24 namespace blink { 25 namespace blink {
25 26
26 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa p; 27 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa p;
27 static InlineTextBoxBlobCacheMap* gTextBlobCache; 28 static InlineTextBoxBlobCacheMap* gTextBlobCache;
28 29
29 static const int misspellingLineThickness = 3; 30 static const int misspellingLineThickness = 3;
30 31
31 void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox) 32 void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox)
32 { 33 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // When only painting the selection, don't bother to paint if there is n one. 76 // When only painting the selection, don't bother to paint if there is n one.
76 return; 77 return;
77 } 78 }
78 79
79 // Determine whether or not we have composition underlines to draw. 80 // Determine whether or not we have composition underlines to draw.
80 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i nlineTextBox.layoutObject().node(); 81 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i nlineTextBox.layoutObject().node();
81 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje ct().frame()->inputMethodController().compositionUsesCustomUnderlines(); 82 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje ct().frame()->inputMethodController().compositionUsesCustomUnderlines();
82 83
83 // The text clip phase already has a DrawingRecorder. Text clips are initiat ed only in BoxPainter::paintLayerExtended, which is already 84 // The text clip phase already has a DrawingRecorder. Text clips are initiat ed only in BoxPainter::paintLayerExtended, which is already
84 // within a DrawingRecorder. 85 // within a DrawingRecorder.
85 OwnPtr<DrawingRecorder> drawingRecorder; 86 Optional<DrawingRecorder> drawingRecorder;
86 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai ntPhaseTextClip) { 87 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai ntPhaseTextClip) {
87 LayoutRect paintRect(m_inlineTextBox.logicalRectToPhysicalRect(logicalVi sualOverflow)); 88 LayoutRect paintRect(m_inlineTextBox.logicalRectToPhysicalRect(logicalVi sualOverflow));
88 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) 89 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject())))
89 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); 90 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s tart(), m_inlineTextBox.start() + m_inlineTextBox.len()));
90 paintRect.moveBy(adjustedPaintOffset); 91 paintRect.moveBy(adjustedPaintOffset);
91 drawingRecorder = adoptPtr(new DrawingRecorder(*paintInfo.context, m_inl ineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase), paintRect)); 92 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem ::paintPhaseToDrawingType(paintInfo.phase), paintRect);
92 if (drawingRecorder->canUseCachedDrawing()) 93 if (drawingRecorder->canUseCachedDrawing())
93 return; 94 return;
94 } 95 }
95 96
96 if (m_inlineTextBox.truncation() != cNoTruncation) { 97 if (m_inlineTextBox.truncation() != cNoTruncation) {
97 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { 98 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR ightDirection() != m_inlineTextBox.isLeftToRightDirection()) {
98 // Make the visible fragment of text hug the edge closest to the res t of the run by moving the origin 99 // Make the visible fragment of text hug the edge closest to the res t of the run by moving the origin
99 // at which we start drawing text. 100 // at which we start drawing text.
100 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is: 101 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is:
101 // |Hello|CBA| -> |...He|CBA| 102 // |Hello|CBA| -> |...He|CBA|
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : 810 LayoutTheme::theme().platformActiveTextSearchHighlightColor() :
810 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); 811 LayoutTheme::theme().platformInactiveTextSearchHighlightColor();
811 GraphicsContextStateSaver stateSaver(*pt); 812 GraphicsContextStateSaver stateSaver(*pt);
812 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); 813 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight));
813 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); 814 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos);
814 } 815 }
815 } 816 }
816 817
817 818
818 } // namespace blink 819 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698