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

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

Issue 1363613002: Save previous paint offset in LayoutObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: No union (many compilers don't allow constructors); Fix a typo perhaps caused by switching to combiā€¦ Created 5 years, 2 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/editing/CompositionUnderline.h" 8 #include "core/editing/CompositionUnderline.h"
9 #include "core/editing/Editor.h" 9 #include "core/editing/Editor.h"
10 #include "core/editing/markers/DocumentMarkerController.h" 10 #include "core/editing/markers/DocumentMarkerController.h"
11 #include "core/editing/markers/RenderedDocumentMarker.h" 11 #include "core/editing/markers/RenderedDocumentMarker.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/layout/LayoutBlock.h" 13 #include "core/layout/LayoutBlock.h"
14 #include "core/layout/LayoutTextCombine.h" 14 #include "core/layout/LayoutTextCombine.h"
15 #include "core/layout/LayoutTheme.h" 15 #include "core/layout/LayoutTheme.h"
16 #include "core/layout/api/LineLayoutBox.h" 16 #include "core/layout/api/LineLayoutBox.h"
17 #include "core/layout/api/LineLayoutText.h" 17 #include "core/layout/api/LineLayoutText.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/LayoutObjectDrawingRecorder.h"
21 #include "core/paint/PaintInfo.h" 20 #include "core/paint/PaintInfo.h"
22 #include "core/paint/TextPainter.h" 21 #include "core/paint/TextPainter.h"
23 #include "platform/graphics/GraphicsContextStateSaver.h" 22 #include "platform/graphics/GraphicsContextStateSaver.h"
23 #include "platform/graphics/paint/DrawingRecorder.h"
24 #include "wtf/Optional.h" 24 #include "wtf/Optional.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa p; 28 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa p;
29 static InlineTextBoxBlobCacheMap* gTextBlobCache; 29 static InlineTextBoxBlobCacheMap* gTextBlobCache;
30 30
31 static const int misspellingLineThickness = 3; 31 static const int misspellingLineThickness = 3;
32 32
33 void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox) 33 void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Determine whether or not we're selected. 78 // Determine whether or not we're selected.
79 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && m_inlineTextBox.selectionState() != SelectionNone; 79 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && m_inlineTextBox.selectionState() != SelectionNone;
80 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { 80 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) {
81 // When only painting the selection, don't bother to paint if there is n one. 81 // When only painting the selection, don't bother to paint if there is n one.
82 return; 82 return;
83 } 83 }
84 84
85 // The text clip phase already has a LayoutObjectDrawingRecorder. Text clips are initiated only in BoxPainter::paintLayerExtended, 85 // The text clip phase already has a LayoutObjectDrawingRecorder. Text clips are initiated only in BoxPainter::paintLayerExtended,
86 // which is already within a LayoutObjectDrawingRecorder. 86 // which is already within a LayoutObjectDrawingRecorder.
87 Optional<LayoutObjectDrawingRecorder> drawingRecorder; 87 Optional<DrawingRecorder> drawingRecorder;
88 if (paintInfo.phase != PaintPhaseTextClip) { 88 if (paintInfo.phase != PaintPhaseTextClip) {
89 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c ontext, m_inlineTextBox, paintInfo.phase, paintOffset)) 89 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase)))
90 return; 90 return;
91 LayoutRect paintRect(logicalVisualOverflow); 91 LayoutRect paintRect(logicalVisualOverflow);
92 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); 92 m_inlineTextBox.logicalRectToPhysicalRect(paintRect);
93 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || paintsMa rkerHighlights(m_inlineTextBox.layoutObject()))) 93 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || paintsMa rkerHighlights(m_inlineTextBox.layoutObject())))
94 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); 94 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s tart(), m_inlineTextBox.start() + m_inlineTextBox.len()));
95 paintRect.moveBy(adjustedPaintOffset); 95 paintRect.moveBy(adjustedPaintOffset);
96 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, paintInfo.p hase, paintRect, paintOffset); 96 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem ::paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect));
97 } 97 }
98 98
99 if (m_inlineTextBox.truncation() != cNoTruncation) { 99 if (m_inlineTextBox.truncation() != cNoTruncation) {
100 if (m_inlineTextBox.lineLayoutItem().containingBlock().style()->isLeftTo RightDirection() != m_inlineTextBox.isLeftToRightDirection()) { 100 if (m_inlineTextBox.lineLayoutItem().containingBlock().style()->isLeftTo RightDirection() != m_inlineTextBox.isLeftToRightDirection()) {
101 // Make the visible fragment of text hug the edge closest to the res t of the run by moving the origin 101 // Make the visible fragment of text hug the edge closest to the res t of the run by moving the origin
102 // at which we start drawing text. 102 // at which we start drawing text.
103 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is: 103 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is:
104 // |Hello|CBA| -> |...He|CBA| 104 // |Hello|CBA| -> |...He|CBA|
105 // In order to draw the fragment "He" aligned to the right edge of i t's box, we need to start drawing 105 // In order to draw the fragment "He" aligned to the right edge of i t's box, we need to start drawing
106 // farther to the right. 106 // farther to the right.
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri cs().ascent()); 847 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri cs().ascent());
848 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline TextBox.isHorizontal()); 848 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline TextBox.isHorizontal());
849 849
850 textPainter.paint(sPos, ePos, length, textStyle, 0); 850 textPainter.paint(sPos, ePos, length, textStyle, 0);
851 } 851 }
852 } 852 }
853 } 853 }
854 854
855 855
856 } // namespace blink 856 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698