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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp

Issue 2929763002: Introduce InlineTextBoxesOf() for ease of loop over InlineTextBox of LayoutText (Closed)
Patch Set: 2017-06-08T17:21:30 Revise variable name in ComputeInlineBoxPositionTempalte to make patch size smaller Created 3 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/Source/core/layout/LayoutText.cpp ('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 /* 1 /*
2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006 Apple Computer Inc. 3 * Copyright (C) 2006 Apple Computer Inc.
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
5 * Copyright (C) 2008 Rob Buis <buis@kde.org> 5 * Copyright (C) 2008 Rob Buis <buis@kde.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 LayoutRect rect = 120 LayoutRect rect =
121 text_box->LocalSelectionRect(caret_offset - 1, caret_offset); 121 text_box->LocalSelectionRect(caret_offset - 1, caret_offset);
122 LayoutUnit x = box->IsLeftToRightDirection() ? rect.MaxX() : rect.X(); 122 LayoutUnit x = box->IsLeftToRightDirection() ? rect.MaxX() : rect.X();
123 return LayoutRect(x, rect.Y(), GetFrameView()->CaretWidth(), rect.Height()); 123 return LayoutRect(x, rect.Y(), GetFrameView()->CaretWidth(), rect.Height());
124 } 124 }
125 125
126 FloatRect LayoutSVGInlineText::FloatLinesBoundingBox() const { 126 FloatRect LayoutSVGInlineText::FloatLinesBoundingBox() const {
127 FloatRect bounding_box; 127 FloatRect bounding_box;
128 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) 128 for (InlineTextBox* box : InlineTextBoxesOf(*this))
129 bounding_box.Unite(FloatRect(box->FrameRect())); 129 bounding_box.Unite(FloatRect(box->FrameRect()));
130 return bounding_box; 130 return bounding_box;
131 } 131 }
132 132
133 LayoutRect LayoutSVGInlineText::LinesBoundingBox() const { 133 LayoutRect LayoutSVGInlineText::LinesBoundingBox() const {
134 return EnclosingLayoutRect(FloatLinesBoundingBox()); 134 return EnclosingLayoutRect(FloatLinesBoundingBox());
135 } 135 }
136 136
137 bool LayoutSVGInlineText::CharacterStartsNewTextChunk(int position) const { 137 bool LayoutSVGInlineText::CharacterStartsNewTextChunk(int position) const {
138 DCHECK_GE(position, 0); 138 DCHECK_GE(position, 0);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Map local point to absolute point, as the character origins stored in the 170 // Map local point to absolute point, as the character origins stored in the
171 // text fragments use absolute coordinates. 171 // text fragments use absolute coordinates.
172 FloatPoint absolute_point(point); 172 FloatPoint absolute_point(point);
173 absolute_point.MoveBy(containing_block->Location()); 173 absolute_point.MoveBy(containing_block->Location());
174 174
175 float closest_distance = std::numeric_limits<float>::max(); 175 float closest_distance = std::numeric_limits<float>::max();
176 float closest_distance_position = 0; 176 float closest_distance_position = 0;
177 const SVGTextFragment* closest_distance_fragment = nullptr; 177 const SVGTextFragment* closest_distance_fragment = nullptr;
178 SVGInlineTextBox* closest_distance_box = nullptr; 178 SVGInlineTextBox* closest_distance_box = nullptr;
179 179
180 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { 180 for (InlineTextBox* box : InlineTextBoxesOf(*this)) {
181 if (!box->IsSVGInlineTextBox()) 181 if (!box->IsSVGInlineTextBox())
182 continue; 182 continue;
183 183
184 SVGInlineTextBox* text_box = ToSVGInlineTextBox(box); 184 SVGInlineTextBox* text_box = ToSVGInlineTextBox(box);
185 for (const SVGTextFragment& fragment : text_box->TextFragments()) { 185 for (const SVGTextFragment& fragment : text_box->TextFragments()) {
186 FloatRect fragment_rect = fragment.BoundingBox(baseline); 186 FloatRect fragment_rect = fragment.BoundingBox(baseline);
187 187
188 float distance = 0; 188 float distance = 0;
189 if (!fragment_rect.Contains(absolute_point)) 189 if (!fragment_rect.Contains(absolute_point))
190 distance = fragment_rect.SquaredDistanceTo(absolute_point); 190 distance = fragment_rect.SquaredDistanceTo(absolute_point);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 423 }
424 424
425 PassRefPtr<StringImpl> LayoutSVGInlineText::OriginalText() const { 425 PassRefPtr<StringImpl> LayoutSVGInlineText::OriginalText() const {
426 RefPtr<StringImpl> result = LayoutText::OriginalText(); 426 RefPtr<StringImpl> result = LayoutText::OriginalText();
427 if (!result) 427 if (!result)
428 return nullptr; 428 return nullptr;
429 return NormalizeWhitespace(result); 429 return NormalizeWhitespace(result);
430 } 430 }
431 431
432 } // namespace blink 432 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutText.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698