| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // Map the <canvas> font into the text style. If the font uses keywords like | 455 // Map the <canvas> font into the text style. If the font uses keywords like |
| 456 // larger/smaller, these will work relative to the canvas. | 456 // larger/smaller, these will work relative to the canvas. |
| 457 RefPtr<ComputedStyle> fontStyle; | 457 RefPtr<ComputedStyle> fontStyle; |
| 458 const ComputedStyle* computedStyle = canvas()->ensureComputedStyle(); | 458 const ComputedStyle* computedStyle = canvas()->ensureComputedStyle(); |
| 459 if (computedStyle) { | 459 if (computedStyle) { |
| 460 HashMap<String, Font>::iterator i = | 460 HashMap<String, Font>::iterator i = |
| 461 m_fontsResolvedUsingCurrentStyle.find(newFont); | 461 m_fontsResolvedUsingCurrentStyle.find(newFont); |
| 462 if (i != m_fontsResolvedUsingCurrentStyle.end()) { | 462 if (i != m_fontsResolvedUsingCurrentStyle.end()) { |
| 463 DCHECK(m_fontLRUList.contains(newFont)); | 463 DCHECK(m_fontLRUList.contains(newFont)); |
| 464 m_fontLRUList.remove(newFont); | 464 m_fontLRUList.remove(newFont); |
| 465 m_fontLRUList.add(newFont); | 465 m_fontLRUList.insert(newFont); |
| 466 modifiableState().setFont( | 466 modifiableState().setFont( |
| 467 i->value, canvas()->document().styleEngine().fontSelector()); | 467 i->value, canvas()->document().styleEngine().fontSelector()); |
| 468 } else { | 468 } else { |
| 469 MutableStylePropertySet* parsedStyle = | 469 MutableStylePropertySet* parsedStyle = |
| 470 canvasFontCache->parseFont(newFont); | 470 canvasFontCache->parseFont(newFont); |
| 471 if (!parsedStyle) | 471 if (!parsedStyle) |
| 472 return; | 472 return; |
| 473 fontStyle = ComputedStyle::create(); | 473 fontStyle = ComputedStyle::create(); |
| 474 FontDescription elementFontDescription( | 474 FontDescription elementFontDescription( |
| 475 computedStyle->getFontDescription()); | 475 computedStyle->getFontDescription()); |
| 476 // Reset the computed size to avoid inheriting the zoom factor from the | 476 // Reset the computed size to avoid inheriting the zoom factor from the |
| 477 // <canvas> element. | 477 // <canvas> element. |
| 478 elementFontDescription.setComputedSize( | 478 elementFontDescription.setComputedSize( |
| 479 elementFontDescription.specifiedSize()); | 479 elementFontDescription.specifiedSize()); |
| 480 fontStyle->setFontDescription(elementFontDescription); | 480 fontStyle->setFontDescription(elementFontDescription); |
| 481 fontStyle->font().update(fontStyle->font().getFontSelector()); | 481 fontStyle->font().update(fontStyle->font().getFontSelector()); |
| 482 canvas()->document().ensureStyleResolver().computeFont(fontStyle.get(), | 482 canvas()->document().ensureStyleResolver().computeFont(fontStyle.get(), |
| 483 *parsedStyle); | 483 *parsedStyle); |
| 484 m_fontsResolvedUsingCurrentStyle.insert(newFont, fontStyle->font()); | 484 m_fontsResolvedUsingCurrentStyle.insert(newFont, fontStyle->font()); |
| 485 DCHECK(!m_fontLRUList.contains(newFont)); | 485 DCHECK(!m_fontLRUList.contains(newFont)); |
| 486 m_fontLRUList.add(newFont); | 486 m_fontLRUList.insert(newFont); |
| 487 pruneLocalFontCache(canvasFontCache->hardMaxFonts()); // hard limit | 487 pruneLocalFontCache(canvasFontCache->hardMaxFonts()); // hard limit |
| 488 m_shouldPruneLocalFontCache = true; // apply soft limit | 488 m_shouldPruneLocalFontCache = true; // apply soft limit |
| 489 modifiableState().setFont( | 489 modifiableState().setFont( |
| 490 fontStyle->font(), canvas()->document().styleEngine().fontSelector()); | 490 fontStyle->font(), canvas()->document().styleEngine().fontSelector()); |
| 491 } | 491 } |
| 492 } else { | 492 } else { |
| 493 Font resolvedFont; | 493 Font resolvedFont; |
| 494 if (!canvasFontCache->getFontUsingDefaultStyle(newFont, resolvedFont)) | 494 if (!canvasFontCache->getFontUsingDefaultStyle(newFont, resolvedFont)) |
| 495 return; | 495 return; |
| 496 modifiableState().setFont( | 496 modifiableState().setFont( |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 } | 1159 } |
| 1160 return true; | 1160 return true; |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 void CanvasRenderingContext2D::resetUsageTracking() { | 1163 void CanvasRenderingContext2D::resetUsageTracking() { |
| 1164 UsageCounters newCounters; | 1164 UsageCounters newCounters; |
| 1165 m_usageCounters = newCounters; | 1165 m_usageCounters = newCounters; |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 } // namespace blink | 1168 } // namespace blink |
| OLD | NEW |