| 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) | 376 const SimpleFontData* fontData = style->font().primaryFont(); |
| 377 if (!style || !fontData) |
| 377 return 0; | 378 return 0; |
| 378 | 379 |
| 379 float zeroWidth = | 380 float zeroWidth = |
| 380 style->getFontMetrics().zeroWidth() / style->effectiveZoom(); | 381 fontData->getFontMetrics().zeroWidth() / style->effectiveZoom(); |
| 381 if (!zeroWidth) | 382 if (!zeroWidth) |
| 382 return 0; | 383 return 0; |
| 383 | 384 |
| 384 return value / zeroWidth; | 385 return value / zeroWidth; |
| 385 } | 386 } |
| 386 | 387 |
| 387 float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const { | 388 float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const { |
| 388 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 389 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 389 if (!style) | 390 const SimpleFontData* fontData = style->font().primaryFont(); |
| 391 if (!style || !fontData) |
| 390 return 0; | 392 return 0; |
| 391 | 393 |
| 392 return value * style->getFontMetrics().zeroWidth() / style->effectiveZoom(); | 394 return value * fontData->getFontMetrics().zeroWidth() / |
| 395 style->effectiveZoom(); |
| 393 } | 396 } |
| 394 | 397 |
| 395 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const { | 398 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const { |
| 396 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 399 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 397 if (!style) | 400 const SimpleFontData* fontData = style->font().primaryFont(); |
| 401 if (!style || !fontData) |
| 398 return 0; | 402 return 0; |
| 399 | 403 |
| 400 // Use of ceil allows a pixel match to the W3Cs expected output of | 404 // Use of ceil allows a pixel match to the W3Cs expected output of |
| 401 // coords-units-03-b.svg, if this causes problems in real world cases maybe it | 405 // coords-units-03-b.svg, if this causes problems in real world cases maybe it |
| 402 // would be best to remove this. | 406 // would be best to remove this. |
| 403 float xHeight = | 407 float xHeight = |
| 404 ceilf(style->getFontMetrics().xHeight() / style->effectiveZoom()); | 408 ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom()); |
| 405 if (!xHeight) | 409 if (!xHeight) |
| 406 return 0; | 410 return 0; |
| 407 | 411 |
| 408 return value / xHeight; | 412 return value / xHeight; |
| 409 } | 413 } |
| 410 | 414 |
| 411 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const { | 415 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const { |
| 412 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 416 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 413 if (!style) | 417 const SimpleFontData* fontData = style->font().primaryFont(); |
| 418 if (!style || !fontData) |
| 414 return 0; | 419 return 0; |
| 415 | 420 |
| 416 // Use of ceil allows a pixel match to the W3Cs expected output of | 421 // Use of ceil allows a pixel match to the W3Cs expected output of |
| 417 // coords-units-03-b.svg, if this causes problems in real world cases maybe it | 422 // coords-units-03-b.svg, if this causes problems in real world cases maybe it |
| 418 // would be best to remove this. | 423 // would be best to remove this. |
| 419 return value * | 424 return value * |
| 420 ceilf(style->getFontMetrics().xHeight() / style->effectiveZoom()); | 425 ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom()); |
| 421 } | 426 } |
| 422 | 427 |
| 423 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const { | 428 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const { |
| 424 if (!m_context) | 429 if (!m_context) |
| 425 return false; | 430 return false; |
| 426 | 431 |
| 427 // Root <svg> element lengths are resolved against the top level viewport. | 432 // Root <svg> element lengths are resolved against the top level viewport. |
| 428 if (m_context->isOutermostSVGSVGElement()) { | 433 if (m_context->isOutermostSVGSVGElement()) { |
| 429 viewportSize = toSVGSVGElement(m_context)->currentViewportSize(); | 434 viewportSize = toSVGSVGElement(m_context)->currentViewportSize(); |
| 430 return true; | 435 return true; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 452 const ComputedStyle* rootStyle = rootElementStyle(m_context); | 457 const ComputedStyle* rootStyle = rootElementStyle(m_context); |
| 453 if (!rootStyle) | 458 if (!rootStyle) |
| 454 return 0; | 459 return 0; |
| 455 | 460 |
| 456 CSSToLengthConversionData conversionData = CSSToLengthConversionData( | 461 CSSToLengthConversionData conversionData = CSSToLengthConversionData( |
| 457 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); | 462 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); |
| 458 Length length = primitiveValue.convertToLength(conversionData); | 463 Length length = primitiveValue.convertToLength(conversionData); |
| 459 return valueForLength(length, 1.0f, mode); | 464 return valueForLength(length, 1.0f, mode); |
| 460 } | 465 } |
| 461 } // namespace blink | 466 } // namespace blink |
| OLD | NEW |