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

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

Issue 1303653002: Introduce LayoutObject::createPositionWithAffinity(int offset) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-19T12:20:28 Created 5 years, 4 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 | « Source/core/layout/LayoutText.cpp ('k') | Source/core/layout/svg/LayoutSVGText.cpp » ('j') | 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const SVGCharacterDataMap::const_iterator it = m_layoutAttributes.characterD ataMap().find(static_cast<unsigned>(position + 1)); 154 const SVGCharacterDataMap::const_iterator it = m_layoutAttributes.characterD ataMap().find(static_cast<unsigned>(position + 1));
155 if (it == m_layoutAttributes.characterDataMap().end()) 155 if (it == m_layoutAttributes.characterDataMap().end())
156 return false; 156 return false;
157 157
158 return !SVGTextLayoutAttributes::isEmptyValue(it->value.x) || !SVGTextLayout Attributes::isEmptyValue(it->value.y); 158 return !SVGTextLayoutAttributes::isEmptyValue(it->value.x) || !SVGTextLayout Attributes::isEmptyValue(it->value.y);
159 } 159 }
160 160
161 PositionWithAffinity LayoutSVGInlineText::positionForPoint(const LayoutPoint& po int) 161 PositionWithAffinity LayoutSVGInlineText::positionForPoint(const LayoutPoint& po int)
162 { 162 {
163 if (!firstTextBox() || !textLength()) 163 if (!firstTextBox() || !textLength())
164 return createPositionWithAffinity(0, DOWNSTREAM); 164 return createPositionWithAffinity(0);
165 165
166 ASSERT(m_scalingFactor); 166 ASSERT(m_scalingFactor);
167 float baseline = m_scaledFont.fontMetrics().floatAscent() / m_scalingFactor; 167 float baseline = m_scaledFont.fontMetrics().floatAscent() / m_scalingFactor;
168 168
169 LayoutBlock* containingBlock = this->containingBlock(); 169 LayoutBlock* containingBlock = this->containingBlock();
170 ASSERT(containingBlock); 170 ASSERT(containingBlock);
171 171
172 // Map local point to absolute point, as the character origins stored in the text fragments use absolute coordinates. 172 // Map local point to absolute point, as the character origins stored in the text fragments use absolute coordinates.
173 FloatPoint absolutePoint(point); 173 FloatPoint absolutePoint(point);
174 absolutePoint.moveBy(containingBlock->location()); 174 absolutePoint.moveBy(containingBlock->location());
(...skipping 26 matching lines...) Expand all
201 if (distance <= closestDistance) { 201 if (distance <= closestDistance) {
202 closestDistance = distance; 202 closestDistance = distance;
203 closestDistanceBox = textBox; 203 closestDistanceBox = textBox;
204 closestDistanceFragment = &fragment; 204 closestDistanceFragment = &fragment;
205 closestDistancePosition = fragmentRect.x(); 205 closestDistancePosition = fragmentRect.x();
206 } 206 }
207 } 207 }
208 } 208 }
209 209
210 if (!closestDistanceFragment) 210 if (!closestDistanceFragment)
211 return createPositionWithAffinity(0, DOWNSTREAM); 211 return createPositionWithAffinity(0);
212 212
213 int offset = closestDistanceBox->offsetForPositionInFragment(*closestDistanc eFragment, absolutePoint.x() - closestDistancePosition, true); 213 int offset = closestDistanceBox->offsetForPositionInFragment(*closestDistanc eFragment, absolutePoint.x() - closestDistancePosition, true);
214 return createPositionWithAffinity(offset + closestDistanceBox->start(), offs et > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM); 214 return createPositionWithAffinity(offset + closestDistanceBox->start(), offs et > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
215 } 215 }
216 216
217 void LayoutSVGInlineText::updateScaledFont() 217 void LayoutSVGInlineText::updateScaledFont()
218 { 218 {
219 computeNewScaledFontForStyle(this, style(), m_scalingFactor, m_scaledFont); 219 computeNewScaledFontForStyle(this, style(), m_scalingFactor, m_scaledFont);
220 } 220 }
221 221
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const 256 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const
257 { 257 {
258 RefPtr<StringImpl> result = LayoutText::originalText(); 258 RefPtr<StringImpl> result = LayoutText::originalText();
259 if (!result) 259 if (!result)
260 return nullptr; 260 return nullptr;
261 return applySVGWhitespaceRules(result, style() && style()->whiteSpace() == P RE); 261 return applySVGWhitespaceRules(result, style() && style()->whiteSpace() == P RE);
262 } 262 }
263 263
264 } 264 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutText.cpp ('k') | Source/core/layout/svg/LayoutSVGText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698