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

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

Issue 2065723002: Don't use selection bounds to paint document marker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use selection bounds to paint document marker Created 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/paint/text/text-match-highlights-big-line-height-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "core/paint/InlineTextBoxPainter.h" 5 #include "core/paint/InlineTextBoxPainter.h"
6 6
7 #include "core/editing/CompositionUnderline.h" 7 #include "core/editing/CompositionUnderline.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/editing/markers/DocumentMarkerController.h" 9 #include "core/editing/markers/DocumentMarkerController.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m _inlineTextBox.isHorizontal()); 825 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m _inlineTextBox.isHorizontal());
826 826
827 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0); 827 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0);
828 } 828 }
829 829
830 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font) 830 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font)
831 { 831 {
832 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem() )->frame()->editor().markedTextMatchesAreHighlighted()) 832 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem() )->frame()->editor().markedTextMatchesAreHighlighted())
833 return; 833 return;
834 834
835 // Use same y positioning and height as for selection, so that when the sele ction and this highlight are on
836 // the same word there are no pieces sticking out.
837 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLinesWrit ingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBo ttom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop();
838 int selHeight = m_inlineTextBox.root().selectionHeight();
839
840 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0); 835 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0);
841 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len()); 836 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len());
842 TextRun run = m_inlineTextBox.constructTextRun(style, font); 837 TextRun run = m_inlineTextBox.constructTextRun(style, font);
843 838
844 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); 839 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch());
845 GraphicsContext& context = paintInfo.context; 840 GraphicsContext& context = paintInfo.context;
846 GraphicsContextStateSaver stateSaver(context); 841 GraphicsContextStateSaver stateSaver(context);
847 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); 842
848 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); 843 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight()));
844 context.clip(FloatRect(boxRect));
845 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh t(), color, sPos, ePos);
849 } 846 }
850 847
851 848
852 } // namespace blink 849 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/paint/text/text-match-highlights-big-line-height-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698