OLD | NEW |
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 default: | 366 default: |
367 break; | 367 break; |
368 } | 368 } |
369 | 369 |
370 ASSERT_NOT_REACHED(); | 370 ASSERT_NOT_REACHED(); |
371 return 0; | 371 return 0; |
372 } | 372 } |
373 | 373 |
374 float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const { | 374 float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const { |
375 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 375 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 376 if (!style) |
| 377 return 0; |
376 const SimpleFontData* fontData = style->font().primaryFont(); | 378 const SimpleFontData* fontData = style->font().primaryFont(); |
377 if (!style || !fontData) | 379 if (!fontData) |
378 return 0; | 380 return 0; |
379 | |
380 float zeroWidth = | 381 float zeroWidth = |
381 fontData->getFontMetrics().zeroWidth() / style->effectiveZoom(); | 382 fontData->getFontMetrics().zeroWidth() / style->effectiveZoom(); |
382 if (!zeroWidth) | 383 if (!zeroWidth) |
383 return 0; | 384 return 0; |
384 | |
385 return value / zeroWidth; | 385 return value / zeroWidth; |
386 } | 386 } |
387 | 387 |
388 float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const { | 388 float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const { |
389 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 389 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
390 if (!style) | 390 if (!style) |
391 return 0; | 391 return 0; |
392 | |
393 const SimpleFontData* fontData = style->font().primaryFont(); | 392 const SimpleFontData* fontData = style->font().primaryFont(); |
394 if (!fontData) | 393 if (!fontData) |
395 return 0; | 394 return 0; |
396 | |
397 return value * fontData->getFontMetrics().zeroWidth() / | 395 return value * fontData->getFontMetrics().zeroWidth() / |
398 style->effectiveZoom(); | 396 style->effectiveZoom(); |
399 } | 397 } |
400 | 398 |
401 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const { | 399 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const { |
402 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 400 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 401 if (!style) |
| 402 return 0; |
403 const SimpleFontData* fontData = style->font().primaryFont(); | 403 const SimpleFontData* fontData = style->font().primaryFont(); |
404 if (!style || !fontData) | 404 if (!fontData) |
405 return 0; | 405 return 0; |
406 | |
407 // Use of ceil allows a pixel match to the W3Cs expected output of | 406 // Use of ceil allows a pixel match to the W3Cs expected output of |
408 // coords-units-03-b.svg, if this causes problems in real world cases maybe it | 407 // coords-units-03-b.svg, if this causes problems in real world cases maybe it |
409 // would be best to remove this. | 408 // would be best to remove this. |
410 float xHeight = | 409 float xHeight = |
411 ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom()); | 410 ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom()); |
412 if (!xHeight) | 411 if (!xHeight) |
413 return 0; | 412 return 0; |
414 | |
415 return value / xHeight; | 413 return value / xHeight; |
416 } | 414 } |
417 | 415 |
418 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const { | 416 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const { |
419 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 417 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 418 if (!style) |
| 419 return 0; |
420 const SimpleFontData* fontData = style->font().primaryFont(); | 420 const SimpleFontData* fontData = style->font().primaryFont(); |
421 if (!style || !fontData) | 421 if (!fontData) |
422 return 0; | 422 return 0; |
423 | |
424 // Use of ceil allows a pixel match to the W3Cs expected output of | 423 // Use of ceil allows a pixel match to the W3Cs expected output of |
425 // coords-units-03-b.svg, if this causes problems in real world cases maybe it | 424 // coords-units-03-b.svg, if this causes problems in real world cases maybe it |
426 // would be best to remove this. | 425 // would be best to remove this. |
427 return value * | 426 return value * |
428 ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom()); | 427 ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom()); |
429 } | 428 } |
430 | 429 |
431 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const { | 430 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const { |
432 if (!m_context) | 431 if (!m_context) |
433 return false; | 432 return false; |
(...skipping 26 matching lines...) Expand all Loading... |
460 const ComputedStyle* rootStyle = rootElementStyle(m_context); | 459 const ComputedStyle* rootStyle = rootElementStyle(m_context); |
461 if (!rootStyle) | 460 if (!rootStyle) |
462 return 0; | 461 return 0; |
463 | 462 |
464 CSSToLengthConversionData conversionData = CSSToLengthConversionData( | 463 CSSToLengthConversionData conversionData = CSSToLengthConversionData( |
465 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); | 464 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); |
466 Length length = primitiveValue.convertToLength(conversionData); | 465 Length length = primitiveValue.convertToLength(conversionData); |
467 return valueForLength(length, 1.0f, mode); | 466 return valueForLength(length, 1.0f, mode); |
468 } | 467 } |
469 } // namespace blink | 468 } // namespace blink |
OLD | NEW |