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

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

Issue 2669213002: Remove spelling markers in disabled and readonly form elements
Patch Set: Using idle task to remove the markers Created 3 years, 9 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/EditingUtilities.h"
8 #include "core/editing/Editor.h" 9 #include "core/editing/Editor.h"
9 #include "core/editing/markers/DocumentMarkerController.h" 10 #include "core/editing/markers/DocumentMarkerController.h"
10 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "core/html/HTMLFormControlElement.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"
20 #include "platform/graphics/paint/DrawingRecorder.h" 22 #include "platform/graphics/paint/DrawingRecorder.h"
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 localOrigin, selHeight, backgroundColor, sPos, 796 localOrigin, selHeight, backgroundColor, sPos,
795 ePos); 797 ePos);
796 } 798 }
797 799
798 void InlineTextBoxPainter::paintDocumentMarkers( 800 void InlineTextBoxPainter::paintDocumentMarkers(
799 const PaintInfo& paintInfo, 801 const PaintInfo& paintInfo,
800 const LayoutPoint& boxOrigin, 802 const LayoutPoint& boxOrigin,
801 const ComputedStyle& style, 803 const ComputedStyle& style,
802 const Font& font, 804 const Font& font,
803 DocumentMarkerPaintPhase markerPaintPhase) { 805 DocumentMarkerPaintPhase markerPaintPhase) {
804 if (!m_inlineTextBox.getLineLayoutItem().node()) 806 const Node* node = m_inlineTextBox.getLineLayoutItem().node();
807 if (!node)
808 return;
809
810 if (!hasEditableStyle(*node) &&
Xiaocheng 2017/03/03 18:24:06 This breaks the rendering of non-spelling markers,
811 (!isHTMLFormControlElement(*node) ||
812 toHTMLFormControlElement(*node).isDisabledOrReadOnly()))
805 return; 813 return;
806 814
807 DCHECK(m_inlineTextBox.truncation() != cFullTruncation); 815 DCHECK(m_inlineTextBox.truncation() != cFullTruncation);
808 DCHECK(m_inlineTextBox.len()); 816 DCHECK(m_inlineTextBox.len());
809 817
810 DocumentMarkerVector markers = 818 DocumentMarkerVector markers =
811 m_inlineTextBox.getLineLayoutItem().document().markers().markersFor( 819 m_inlineTextBox.getLineLayoutItem().document().markers().markersFor(
812 m_inlineTextBox.getLineLayoutItem().node()); 820 m_inlineTextBox.getLineLayoutItem().node());
813 DocumentMarkerVector::const_iterator markerIt = markers.begin(); 821 DocumentMarkerVector::const_iterator markerIt = markers.begin();
814 822
815 // Give any document markers that touch this run a chance to draw before the 823 // Give any document markers that touch this run a chance to draw before the
816 // text has been drawn. Note end() points at the last char, not one past it 824 // text has been drawn. Note end() points at the last char, not one past it
817 // like endOffset and ranges do. 825 // like endOffset and ranges do.
818 for (; markerIt != markers.end(); ++markerIt) { 826 for (; markerIt != markers.end(); ++markerIt) {
819 DCHECK(*markerIt); 827 DCHECK(*markerIt);
820 const DocumentMarker& marker = **markerIt; 828 const DocumentMarker& marker = **markerIt;
821 829
822 // Paint either the background markers or the foreground markers, but not 830 // Paint either the background markers or the foreground markers, but not
823 // both. 831 // both.
824 switch (marker.type()) { 832 switch (marker.type()) {
825 case DocumentMarker::Grammar: 833 case DocumentMarker::Grammar:
826 case DocumentMarker::Spelling: 834 case DocumentMarker::Spelling:
827 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) 835 if (markerPaintPhase == DocumentMarkerPaintPhase::Background)
828 continue; 836 continue;
829 break; 837 break;
Xiaocheng 2017/03/03 18:24:06 The check should be added here.
830 case DocumentMarker::TextMatch: 838 case DocumentMarker::TextMatch:
831 case DocumentMarker::Composition: 839 case DocumentMarker::Composition:
832 break; 840 break;
833 default: 841 default:
834 continue; 842 continue;
835 } 843 }
836 844
837 if (marker.endOffset() <= m_inlineTextBox.start()) { 845 if (marker.endOffset() <= m_inlineTextBox.start()) {
838 // marker is completely before this run. This might be a marker that sits 846 // marker is completely before this run. This might be a marker that sits
839 // before the first run we draw, or markers that were within runs we 847 // before the first run we draw, or markers that were within runs we
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 1369
1362 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), 1370 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(),
1363 m_inlineTextBox.logicalHeight())); 1371 m_inlineTextBox.logicalHeight()));
1364 context.clip(FloatRect(boxRect)); 1372 context.clip(FloatRect(boxRect));
1365 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), 1373 context.drawHighlightForText(font, run, FloatPoint(boxOrigin),
1366 boxRect.height().toInt(), color, 1374 boxRect.height().toInt(), color,
1367 paintOffsets.first, paintOffsets.second); 1375 paintOffsets.first, paintOffsets.second);
1368 } 1376 }
1369 1377
1370 } // namespace blink 1378 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698