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

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

Issue 2843483002: Tidy up fragment loops in SVGInlineTextBoxPainter (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | 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/SVGInlineTextBoxPainter.h" 5 #include "core/paint/SVGInlineTextBoxPainter.h"
6 6
7 #include "core/editing/Editor.h" 7 #include "core/editing/Editor.h"
8 #include "core/editing/markers/DocumentMarkerController.h" 8 #include "core/editing/markers/DocumentMarkerController.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } else { 160 } else {
161 selection_style = &style; 161 selection_style = &style;
162 } 162 }
163 } 163 }
164 164
165 if (paint_info.IsRenderingClipPathAsMaskImage()) { 165 if (paint_info.IsRenderingClipPathAsMaskImage()) {
166 has_fill = true; 166 has_fill = true;
167 has_visible_stroke = false; 167 has_visible_stroke = false;
168 } 168 }
169 169
170 unsigned text_fragments_size = svg_inline_text_box_.TextFragments().size(); 170 for (const SVGTextFragment& fragment : svg_inline_text_box_.TextFragments()) {
171 for (unsigned i = 0; i < text_fragments_size; ++i) {
172 const SVGTextFragment& fragment =
173 svg_inline_text_box_.TextFragments().at(i);
174
175 GraphicsContextStateSaver state_saver(paint_info.context, false); 171 GraphicsContextStateSaver state_saver(paint_info.context, false);
176 if (fragment.IsTransformed()) { 172 if (fragment.IsTransformed()) {
177 state_saver.Save(); 173 state_saver.Save();
178 paint_info.context.ConcatCTM(fragment.BuildFragmentTransform()); 174 paint_info.context.ConcatCTM(fragment.BuildFragmentTransform());
179 } 175 }
180 176
181 // Spec: All text decorations except line-through should be drawn before the 177 // Spec: All text decorations except line-through should be drawn before the
182 // text is filled and stroked; thus, the text is rendered on top of these 178 // text is filled and stroked; thus, the text is rendered on top of these
183 // decorations. 179 // decorations.
184 const Vector<AppliedTextDecoration>& decorations = 180 const Vector<AppliedTextDecoration>& decorations =
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 if (marker_start_position >= marker_end_position) 576 if (marker_start_position >= marker_end_position)
581 return empty_text_match_list; 577 return empty_text_match_list;
582 578
583 return CollectFragmentsInRange(marker_start_position, marker_end_position); 579 return CollectFragmentsInRange(marker_start_position, marker_end_position);
584 } 580 }
585 581
586 Vector<SVGTextFragmentWithRange> 582 Vector<SVGTextFragmentWithRange>
587 SVGInlineTextBoxPainter::CollectFragmentsInRange(int start_position, 583 SVGInlineTextBoxPainter::CollectFragmentsInRange(int start_position,
588 int end_position) const { 584 int end_position) const {
589 Vector<SVGTextFragmentWithRange> fragment_info_list; 585 Vector<SVGTextFragmentWithRange> fragment_info_list;
590 const Vector<SVGTextFragment>& fragments = 586 for (const SVGTextFragment& fragment : svg_inline_text_box_.TextFragments()) {
591 svg_inline_text_box_.TextFragments();
592 for (const SVGTextFragment& fragment : fragments) {
593 // TODO(ramya.v): If these can't be negative we should use unsigned. 587 // TODO(ramya.v): If these can't be negative we should use unsigned.
594 int fragment_start_position = start_position; 588 int fragment_start_position = start_position;
595 int fragment_end_position = end_position; 589 int fragment_end_position = end_position;
596 if (!svg_inline_text_box_.MapStartEndPositionsIntoFragmentCoordinates( 590 if (!svg_inline_text_box_.MapStartEndPositionsIntoFragmentCoordinates(
597 fragment, fragment_start_position, fragment_end_position)) 591 fragment, fragment_start_position, fragment_end_position))
598 continue; 592 continue;
599 593
600 fragment_info_list.push_back(SVGTextFragmentWithRange( 594 fragment_info_list.push_back(SVGTextFragmentWithRange(
601 fragment, fragment_start_position, fragment_end_position)); 595 fragment, fragment_start_position, fragment_end_position));
602 } 596 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 } 662 }
669 FloatRect fragment_rect = svg_inline_text_box_.SelectionRectForTextFragment( 663 FloatRect fragment_rect = svg_inline_text_box_.SelectionRectForTextFragment(
670 fragment, text_match_info.start_position, text_match_info.end_position, 664 fragment, text_match_info.start_position, text_match_info.end_position,
671 style); 665 style);
672 paint_info.context.SetFillColor(color); 666 paint_info.context.SetFillColor(color);
673 paint_info.context.FillRect(fragment_rect); 667 paint_info.context.FillRect(fragment_rect);
674 } 668 }
675 } 669 }
676 670
677 } // namespace blink 671 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698