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

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 567543002: Avoid re-parsing of string in fillText and measureText in Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating test expectation file Created 6 years, 2 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/platform/fonts/Font.h ('k') | Source/platform/fonts/WidthIterator.h » ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (data.glyph != verticalRightData.glyph) 420 if (data.glyph != verticalRightData.glyph)
421 return std::make_pair(data, page); 421 return std::make_pair(data, page);
422 // The glyphs are identical, meaning that we should just use the hor izontal glyph. 422 // The glyphs are identical, meaning that we should just use the hor izontal glyph.
423 if (verticalRightData.fontData) 423 if (verticalRightData.fontData)
424 return std::make_pair(verticalRightData, verticalRightPage); 424 return std::make_pair(verticalRightData, verticalRightPage);
425 } 425 }
426 } 426 }
427 return std::make_pair(data, page); 427 return std::make_pair(data, page);
428 } 428 }
429 429
430 std::pair<GlyphData, GlyphPage*> Font::glyphDataAndPageForCharacter(UChar32 c, b ool mirror, FontDataVariant variant) const 430 std::pair<GlyphData, GlyphPage*> Font::glyphDataAndPageForCharacter(UChar32& c, bool mirror, bool normalizeSpace, FontDataVariant variant) const
431 { 431 {
432 ASSERT(isMainThread()); 432 ASSERT(isMainThread());
433 433
434 if (variant == AutoVariant) { 434 if (variant == AutoVariant) {
435 if (m_fontDescription.variant() == FontVariantSmallCaps && !primaryFont( )->isSVGFont()) { 435 if (m_fontDescription.variant() == FontVariantSmallCaps && !primaryFont( )->isSVGFont()) {
436 UChar32 upperC = toUpper(c); 436 UChar32 upperC = toUpper(c);
437 if (upperC != c) { 437 if (upperC != c) {
438 c = upperC; 438 c = upperC;
439 variant = SmallCapsVariant; 439 variant = SmallCapsVariant;
440 } else { 440 } else {
441 variant = NormalVariant; 441 variant = NormalVariant;
442 } 442 }
443 } else { 443 } else {
444 variant = NormalVariant; 444 variant = NormalVariant;
445 } 445 }
446 } 446 }
447 447
448 if (normalizeSpace && Character::isNormalizedCanvasSpaceCharacter(c))
449 c = space;
450
448 if (mirror) 451 if (mirror)
449 c = mirroredChar(c); 452 c = mirroredChar(c);
450 453
451 unsigned pageNumber = (c / GlyphPage::size); 454 unsigned pageNumber = (c / GlyphPage::size);
452 455
453 GlyphPageTreeNode* node = m_fontFallbackList->getPageNode(pageNumber); 456 GlyphPageTreeNode* node = m_fontFallbackList->getPageNode(pageNumber);
454 if (!node) { 457 if (!node) {
455 node = GlyphPageTreeNode::getRootChild(fontDataAt(0), pageNumber); 458 node = GlyphPageTreeNode::getRootChild(fontDataAt(0), pageNumber);
456 m_fontFallbackList->setPageNode(pageNumber, node); 459 m_fontFallbackList->setPageNode(pageNumber, node);
457 } 460 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 if (mark.length() < 2) 598 if (mark.length() < 2)
596 return false; 599 return false;
597 600
598 UChar low = mark[1]; 601 UChar low = mark[1];
599 if (!U16_IS_TRAIL(low)) 602 if (!U16_IS_TRAIL(low))
600 return false; 603 return false;
601 604
602 character = U16_GET_SUPPLEMENTARY(character, low); 605 character = U16_GET_SUPPLEMENTARY(character, low);
603 } 606 }
604 607
605 glyphData = glyphDataForCharacter(character, false, EmphasisMarkVariant); 608 bool normalizeSpace = false;
609 glyphData = glyphDataForCharacter(character, false, normalizeSpace, Emphasis MarkVariant);
606 return true; 610 return true;
607 } 611 }
608 612
609 int Font::emphasisMarkAscent(const AtomicString& mark) const 613 int Font::emphasisMarkAscent(const AtomicString& mark) const
610 { 614 {
611 FontCachePurgePreventer purgePreventer; 615 FontCachePurgePreventer purgePreventer;
612 616
613 GlyphData markGlyphData; 617 GlyphData markGlyphData;
614 if (!getEmphasisMarkGlyphData(mark, markGlyphData)) 618 if (!getEmphasisMarkGlyphData(mark, markGlyphData))
615 return 0; 619 return 0;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 if (delta <= 0) 896 if (delta <= 0)
893 break; 897 break;
894 } 898 }
895 } 899 }
896 } 900 }
897 901
898 return offset; 902 return offset;
899 } 903 }
900 904
901 } // namespace blink 905 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/Font.h ('k') | Source/platform/fonts/WidthIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698