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

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

Issue 2780313002: [WIP] Refactor DocumentMarker (Closed)
Patch Set: Move accessor methods into derived classes Created 3 years, 8 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
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/CompositionMarker.h"
9 #include "core/editing/markers/DocumentMarkerController.h" 10 #include "core/editing/markers/DocumentMarkerController.h"
11 #include "core/editing/markers/TextMatchMarker.h"
10 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
11 #include "core/layout/LayoutTextCombine.h" 13 #include "core/layout/LayoutTextCombine.h"
12 #include "core/layout/LayoutTheme.h" 14 #include "core/layout/LayoutTheme.h"
13 #include "core/layout/api/LineLayoutAPIShim.h" 15 #include "core/layout/api/LineLayoutAPIShim.h"
14 #include "core/layout/api/LineLayoutBox.h" 16 #include "core/layout/api/LineLayoutBox.h"
15 #include "core/layout/line/InlineTextBox.h" 17 #include "core/layout/line/InlineTextBox.h"
16 #include "core/paint/PaintInfo.h" 18 #include "core/paint/PaintInfo.h"
17 #include "core/paint/TextPainter.h" 19 #include "core/paint/TextPainter.h"
18 #include "core/style/AppliedTextDecoration.h" 20 #include "core/style/AppliedTextDecoration.h"
19 #include "platform/graphics/GraphicsContextStateSaver.h" 21 #include "platform/graphics/GraphicsContextStateSaver.h"
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 switch (marker.type()) { 851 switch (marker.type()) {
850 case DocumentMarker::Spelling: 852 case DocumentMarker::Spelling:
851 m_inlineTextBox.paintDocumentMarker(paintInfo.context, boxOrigin, 853 m_inlineTextBox.paintDocumentMarker(paintInfo.context, boxOrigin,
852 marker, style, font, false); 854 marker, style, font, false);
853 break; 855 break;
854 case DocumentMarker::Grammar: 856 case DocumentMarker::Grammar:
855 m_inlineTextBox.paintDocumentMarker(paintInfo.context, boxOrigin, 857 m_inlineTextBox.paintDocumentMarker(paintInfo.context, boxOrigin,
856 marker, style, font, true); 858 marker, style, font, true);
857 break; 859 break;
858 case DocumentMarker::TextMatch: 860 case DocumentMarker::TextMatch:
859 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) 861 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) {
860 m_inlineTextBox.paintTextMatchMarkerBackground(paintInfo, boxOrigin, 862 m_inlineTextBox.paintTextMatchMarkerBackground(
861 marker, style, font); 863 paintInfo, boxOrigin, toTextMatchMarker(marker), style, font);
862 else 864 } else {
863 m_inlineTextBox.paintTextMatchMarkerForeground(paintInfo, boxOrigin, 865 m_inlineTextBox.paintTextMatchMarkerForeground(
864 marker, style, font); 866 paintInfo, boxOrigin, toTextMatchMarker(marker), style, font);
867 }
865 break; 868 break;
866 case DocumentMarker::Composition: { 869 case DocumentMarker::Composition: {
867 CompositionUnderline underline(marker.startOffset(), marker.endOffset(), 870 const CompositionMarker& compositionMarker =
868 marker.underlineColor(), marker.thick(), 871 toCompositionMarker(marker);
869 marker.backgroundColor()); 872 CompositionUnderline underline(
873 compositionMarker.startOffset(), compositionMarker.endOffset(),
874 compositionMarker.underlineColor(), compositionMarker.thick(),
875 compositionMarker.backgroundColor());
870 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) 876 if (markerPaintPhase == DocumentMarkerPaintPhase::Background)
871 paintSingleCompositionBackgroundRun( 877 paintSingleCompositionBackgroundRun(
872 paintInfo.context, boxOrigin, style, font, 878 paintInfo.context, boxOrigin, style, font,
873 underline.backgroundColor(), underlinePaintStart(underline), 879 underline.backgroundColor(), underlinePaintStart(underline),
874 underlinePaintEnd(underline)); 880 underlinePaintEnd(underline));
875 else 881 else
876 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); 882 paintCompositionUnderline(paintInfo.context, boxOrigin, underline);
877 } break; 883 } break;
878 default: 884 default:
879 ASSERT_NOT_REACHED(); 885 ASSERT_NOT_REACHED();
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 FloatPoint( 1302 FloatPoint(
1297 boxOrigin.x() + start, 1303 boxOrigin.x() + start,
1298 (boxOrigin.y() + m_inlineTextBox.logicalHeight() - lineThickness) 1304 (boxOrigin.y() + m_inlineTextBox.logicalHeight() - lineThickness)
1299 .toFloat()), 1305 .toFloat()),
1300 width); 1306 width);
1301 } 1307 }
1302 1308
1303 void InlineTextBoxPainter::paintTextMatchMarkerForeground( 1309 void InlineTextBoxPainter::paintTextMatchMarkerForeground(
1304 const PaintInfo& paintInfo, 1310 const PaintInfo& paintInfo,
1305 const LayoutPoint& boxOrigin, 1311 const LayoutPoint& boxOrigin,
1306 const DocumentMarker& marker, 1312 const TextMatchMarker& marker,
1307 const ComputedStyle& style, 1313 const ComputedStyle& style,
1308 const Font& font) { 1314 const Font& font) {
1309 if (!inlineLayoutObject().frame()->editor().markedTextMatchesAreHighlighted()) 1315 if (!inlineLayoutObject().frame()->editor().markedTextMatchesAreHighlighted())
1310 return; 1316 return;
1311 1317
1312 const auto paintOffsets = GetMarkerPaintOffsets(marker, m_inlineTextBox); 1318 const auto paintOffsets = GetMarkerPaintOffsets(marker, m_inlineTextBox);
1313 TextRun run = m_inlineTextBox.constructTextRun(style); 1319 TextRun run = m_inlineTextBox.constructTextRun(style);
1314 1320
1315 Color textColor = 1321 Color textColor =
1316 LayoutTheme::theme().platformTextSearchColor(marker.activeMatch()); 1322 LayoutTheme::theme().platformTextSearchColor(marker.activeMatch());
(...skipping 18 matching lines...) Expand all
1335 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, 1341 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect,
1336 m_inlineTextBox.isHorizontal()); 1342 m_inlineTextBox.isHorizontal());
1337 1343
1338 textPainter.paint(paintOffsets.first, paintOffsets.second, 1344 textPainter.paint(paintOffsets.first, paintOffsets.second,
1339 m_inlineTextBox.len(), textStyle); 1345 m_inlineTextBox.len(), textStyle);
1340 } 1346 }
1341 1347
1342 void InlineTextBoxPainter::paintTextMatchMarkerBackground( 1348 void InlineTextBoxPainter::paintTextMatchMarkerBackground(
1343 const PaintInfo& paintInfo, 1349 const PaintInfo& paintInfo,
1344 const LayoutPoint& boxOrigin, 1350 const LayoutPoint& boxOrigin,
1345 const DocumentMarker& marker, 1351 const TextMatchMarker& marker,
1346 const ComputedStyle& style, 1352 const ComputedStyle& style,
1347 const Font& font) { 1353 const Font& font) {
1348 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem()) 1354 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem())
1349 ->frame() 1355 ->frame()
1350 ->editor() 1356 ->editor()
1351 .markedTextMatchesAreHighlighted()) 1357 .markedTextMatchesAreHighlighted())
1352 return; 1358 return;
1353 1359
1354 const auto paintOffsets = GetMarkerPaintOffsets(marker, m_inlineTextBox); 1360 const auto paintOffsets = GetMarkerPaintOffsets(marker, m_inlineTextBox);
1355 TextRun run = m_inlineTextBox.constructTextRun(style); 1361 TextRun run = m_inlineTextBox.constructTextRun(style);
1356 1362
1357 Color color = LayoutTheme::theme().platformTextSearchHighlightColor( 1363 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(
1358 marker.activeMatch()); 1364 marker.activeMatch());
1359 GraphicsContext& context = paintInfo.context; 1365 GraphicsContext& context = paintInfo.context;
1360 GraphicsContextStateSaver stateSaver(context); 1366 GraphicsContextStateSaver stateSaver(context);
1361 1367
1362 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), 1368 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(),
1363 m_inlineTextBox.logicalHeight())); 1369 m_inlineTextBox.logicalHeight()));
1364 context.clip(FloatRect(boxRect)); 1370 context.clip(FloatRect(boxRect));
1365 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), 1371 context.drawHighlightForText(font, run, FloatPoint(boxOrigin),
1366 boxRect.height().toInt(), color, 1372 boxRect.height().toInt(), color,
1367 paintOffsets.first, paintOffsets.second); 1373 paintOffsets.first, paintOffsets.second);
1368 } 1374 }
1369 1375
1370 } // namespace blink 1376 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698