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

Side by Side Diff: Source/core/svg/SVGLengthContext.cpp

Issue 1283463003: Remove effective zoom from font metrics before length calculations (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid hardcoded values in test 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 | « LayoutTests/svg/custom/zoomed-ex-em-font-sizes.html ('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) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ASSERT_NOT_REACHED(); 281 ASSERT_NOT_REACHED();
282 return 0; 282 return 0;
283 } 283 }
284 284
285 float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const 285 float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const
286 { 286 {
287 const ComputedStyle* style = computedStyleForLengthResolving(m_context); 287 const ComputedStyle* style = computedStyleForLengthResolving(m_context);
288 if (!style) 288 if (!style)
289 return 0; 289 return 0;
290 290
291 float zeroWidth = style->fontMetrics().zeroWidth(); 291 float zeroWidth = style->fontMetrics().zeroWidth() / style->effectiveZoom();
292 if (!zeroWidth) 292 if (!zeroWidth)
293 return 0; 293 return 0;
294 294
295 return value / zeroWidth; 295 return value / zeroWidth;
296 } 296 }
297 297
298 float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const 298 float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const
299 { 299 {
300 const ComputedStyle* style = computedStyleForLengthResolving(m_context); 300 const ComputedStyle* style = computedStyleForLengthResolving(m_context);
301 if (!style) 301 if (!style)
302 return 0; 302 return 0;
303 303
304 return value * style->fontMetrics().zeroWidth(); 304 return value * style->fontMetrics().zeroWidth() / style->effectiveZoom();
305 } 305 }
306 306
307 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const 307 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const
308 { 308 {
309 const ComputedStyle* style = computedStyleForLengthResolving(m_context); 309 const ComputedStyle* style = computedStyleForLengthResolving(m_context);
310 if (!style) 310 if (!style)
311 return 0; 311 return 0;
312 312
313 // Use of ceil allows a pixel match to the W3Cs expected output of coords-un its-03-b.svg 313 // Use of ceil allows a pixel match to the W3Cs expected output of coords-un its-03-b.svg
314 // if this causes problems in real world cases maybe it would be best to rem ove this 314 // if this causes problems in real world cases maybe it would be best to rem ove this
315 float xHeight = ceilf(style->fontMetrics().xHeight()); 315 float xHeight = ceilf(style->fontMetrics().xHeight() / style->effectiveZoom( ));
316 if (!xHeight) 316 if (!xHeight)
317 return 0; 317 return 0;
318 318
319 return value / xHeight; 319 return value / xHeight;
320 } 320 }
321 321
322 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const 322 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const
323 { 323 {
324 const ComputedStyle* style = computedStyleForLengthResolving(m_context); 324 const ComputedStyle* style = computedStyleForLengthResolving(m_context);
325 if (!style) 325 if (!style)
326 return 0; 326 return 0;
327 327
328 // Use of ceil allows a pixel match to the W3Cs expected output of coords-un its-03-b.svg 328 // Use of ceil allows a pixel match to the W3Cs expected output of coords-un its-03-b.svg
329 // if this causes problems in real world cases maybe it would be best to rem ove this 329 // if this causes problems in real world cases maybe it would be best to rem ove this
330 return value * ceilf(style->fontMetrics().xHeight()); 330 return value * ceilf(style->fontMetrics().xHeight() / style->effectiveZoom() );
331 } 331 }
332 332
333 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const 333 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const
334 { 334 {
335 if (!m_context) 335 if (!m_context)
336 return false; 336 return false;
337 337
338 // Root <svg> element lengths are resolved against the top level viewport. 338 // Root <svg> element lengths are resolved against the top level viewport.
339 if (m_context->isOutermostSVGSVGElement()) { 339 if (m_context->isOutermostSVGSVGElement()) {
340 viewportSize = toSVGSVGElement(m_context)->currentViewportSize(); 340 viewportSize = toSVGSVGElement(m_context)->currentViewportSize();
341 return true; 341 return true;
342 } 342 }
343 343
344 // Take size from nearest viewport element. 344 // Take size from nearest viewport element.
345 SVGElement* viewportElement = m_context->viewportElement(); 345 SVGElement* viewportElement = m_context->viewportElement();
346 if (!isSVGSVGElement(viewportElement)) 346 if (!isSVGSVGElement(viewportElement))
347 return false; 347 return false;
348 348
349 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); 349 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement);
350 viewportSize = svg.currentViewBoxRect().size(); 350 viewportSize = svg.currentViewBoxRect().size();
351 if (viewportSize.isEmpty()) 351 if (viewportSize.isEmpty())
352 viewportSize = svg.currentViewportSize(); 352 viewportSize = svg.currentViewportSize();
353 353
354 return true; 354 return true;
355 } 355 }
356 356
357 } 357 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/custom/zoomed-ex-em-font-sizes.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698