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

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

Issue 1072403007: Fixup a bug about SVG text selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Draft 13 Created 5 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 /* 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 SVGInlineTextBox* textBox = toSVGInlineTextBox(box); 177 SVGInlineTextBox* textBox = toSVGInlineTextBox(box);
178 Vector<SVGTextFragment>& fragments = textBox->textFragments(); 178 Vector<SVGTextFragment>& fragments = textBox->textFragments();
179 179
180 unsigned textFragmentsSize = fragments.size(); 180 unsigned textFragmentsSize = fragments.size();
181 for (unsigned i = 0; i < textFragmentsSize; ++i) { 181 for (unsigned i = 0; i < textFragmentsSize; ++i) {
182 const SVGTextFragment& fragment = fragments.at(i); 182 const SVGTextFragment& fragment = fragments.at(i);
183 FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.w idth, fragment.height); 183 FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.w idth, fragment.height);
184 fragment.buildFragmentTransform(fragmentTransform); 184 fragment.buildFragmentTransform(fragmentTransform);
185 fragmentRect = fragmentTransform.mapRect(fragmentRect); 185 fragmentRect = fragmentTransform.mapRect(fragmentRect);
186 186
187 float distance = powf(fragmentRect.x() - absolutePoint.x(), 2) + 187 float distance = 0;
188 powf(fragmentRect.y() + fragmentRect.height() / 2 - absolutePoin t.y(), 2); 188 if (!fragmentRect.contains(absolutePoint)) {
189 // Discard decimal point.
190 distance = floorf(fragmentRect.distanceFromPoint(absolutePoint)) ;
191 }
189 192
190 if (distance < closestDistance) { 193 if (distance <= closestDistance) {
191 closestDistance = distance; 194 closestDistance = distance;
192 closestDistanceBox = textBox; 195 closestDistanceBox = textBox;
193 closestDistanceFragment = &fragment; 196 closestDistanceFragment = &fragment;
194 closestDistancePosition = fragmentRect.x(); 197 closestDistancePosition = fragmentRect.x();
195 } 198 }
196 } 199 }
197 } 200 }
198 201
199 if (!closestDistanceFragment) 202 if (!closestDistanceFragment)
200 return createPositionWithAffinity(0, DOWNSTREAM); 203 return createPositionWithAffinity(0, DOWNSTREAM);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 247
245 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const 248 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const
246 { 249 {
247 RefPtr<StringImpl> result = LayoutText::originalText(); 250 RefPtr<StringImpl> result = LayoutText::originalText();
248 if (!result) 251 if (!result)
249 return nullptr; 252 return nullptr;
250 return applySVGWhitespaceRules(result, style() && style()->whiteSpace() == P RE); 253 return applySVGWhitespaceRules(result, style() && style()->whiteSpace() == P RE);
251 } 254 }
252 255
253 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698