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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/SimpleShaper.cpp

Issue 1743803002: Rename enums/functions that collide in chromium style in core/style/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get-names-8
Patch Set: get-names-9: rebase Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Holger Hans Peter Freyther
4 * Copyright (C) 2014 Google Inc. All rights reserved. 4 * Copyright (C) 2014 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 , m_currentCharacter(0) 42 , m_currentCharacter(0)
43 , m_runWidthSoFar(0) 43 , m_runWidthSoFar(0)
44 { 44 {
45 // If the padding is non-zero, count the number of spaces in the run 45 // If the padding is non-zero, count the number of spaces in the run
46 // and divide that by the padding for per space addition. 46 // and divide that by the padding for per space addition.
47 m_expansion = m_textRun.expansion(); 47 m_expansion = m_textRun.expansion();
48 if (!m_expansion) { 48 if (!m_expansion) {
49 m_expansionPerOpportunity = 0; 49 m_expansionPerOpportunity = 0;
50 } else { 50 } else {
51 bool isAfterExpansion = m_isAfterExpansion; 51 bool isAfterExpansion = m_isAfterExpansion;
52 unsigned expansionOpportunityCount = m_textRun.is8Bit() ? Character::exp ansionOpportunityCount(m_textRun.characters8(), m_textRun.length(), m_textRun.di rection(), isAfterExpansion, m_textRun.textJustify()) : Character::expansionOppo rtunityCount(m_textRun.characters16(), m_textRun.length(), m_textRun.direction() , isAfterExpansion, m_textRun.textJustify()); 52 unsigned expansionOpportunityCount = m_textRun.is8Bit() ? Character::exp ansionOpportunityCount(m_textRun.characters8(), m_textRun.length(), m_textRun.di rection(), isAfterExpansion, m_textRun.getTextJustify()) : Character::expansionO pportunityCount(m_textRun.characters16(), m_textRun.length(), m_textRun.directio n(), isAfterExpansion, m_textRun.getTextJustify());
53 if (isAfterExpansion && !m_textRun.allowsTrailingExpansion()) 53 if (isAfterExpansion && !m_textRun.allowsTrailingExpansion())
54 expansionOpportunityCount--; 54 expansionOpportunityCount--;
55 55
56 if (!expansionOpportunityCount) 56 if (!expansionOpportunityCount)
57 m_expansionPerOpportunity = 0; 57 m_expansionPerOpportunity = 0;
58 else 58 else
59 m_expansionPerOpportunity = m_expansion / expansionOpportunityCount; 59 m_expansionPerOpportunity = m_expansion / expansionOpportunityCount;
60 } 60 }
61 } 61 }
62 62
63 GlyphData SimpleShaper::glyphDataForCharacter(CharacterData& charData, bool norm alizeSpace) 63 GlyphData SimpleShaper::glyphDataForCharacter(CharacterData& charData, bool norm alizeSpace)
64 { 64 {
65 ASSERT(m_font); 65 ASSERT(m_font);
66 return m_font->glyphDataForCharacter(charData.character, m_textRun.rtl(), no rmalizeSpace); 66 return m_font->glyphDataForCharacter(charData.character, m_textRun.rtl(), no rmalizeSpace);
67 } 67 }
68 68
69 float SimpleShaper::characterWidth(UChar32 character, const GlyphData& glyphData ) const 69 float SimpleShaper::characterWidth(UChar32 character, const GlyphData& glyphData ) const
70 { 70 {
71 const SimpleFontData* fontData = glyphData.fontData; 71 const SimpleFontData* fontData = glyphData.fontData;
72 ASSERT(fontData); 72 ASSERT(fontData);
73 73
74 if (UNLIKELY(character == tabulationCharacter && m_textRun.allowTabs())) 74 if (UNLIKELY(character == tabulationCharacter && m_textRun.allowTabs()))
75 return m_font->tabWidth(*fontData, m_textRun.tabSize(), m_textRun.xPos() + m_runWidthSoFar); 75 return m_font->tabWidth(*fontData, m_textRun.getTabSize(), m_textRun.xPo s() + m_runWidthSoFar);
76 76
77 float width = fontData->widthForGlyph(glyphData.glyph); 77 float width = fontData->widthForGlyph(glyphData.glyph);
78 78
79 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squ eeze text. 79 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squ eeze text.
80 if (UNLIKELY(m_textRun.horizontalGlyphStretch() != 1)) 80 if (UNLIKELY(m_textRun.horizontalGlyphStretch() != 1))
81 width *= m_textRun.horizontalGlyphStretch(); 81 width *= m_textRun.horizontalGlyphStretch();
82 82
83 return width; 83 return width;
84 } 84 }
85 85
86 float SimpleShaper::adjustSpacing(float width, const CharacterData& charData) 86 float SimpleShaper::adjustSpacing(float width, const CharacterData& charData)
87 { 87 {
88 // Account for letter-spacing. 88 // Account for letter-spacing.
89 if (width) 89 if (width)
90 width += m_font->fontDescription().letterSpacing(); 90 width += m_font->fontDescription().letterSpacing();
91 91
92 bool isExpansionOpportunity = Character::treatAsSpace(charData.character) || (m_textRun.textJustify() == TextJustifyDistribute); 92 bool isExpansionOpportunity = Character::treatAsSpace(charData.character) || (m_textRun.getTextJustify() == TextJustifyDistribute);
93 if (isExpansionOpportunity || (m_textRun.textJustify() == TextJustifyAuto && Character::isCJKIdeographOrSymbol(charData.character))) { 93 if (isExpansionOpportunity || (m_textRun.getTextJustify() == TextJustifyAuto && Character::isCJKIdeographOrSymbol(charData.character))) {
94 // Distribute the run's total expansion evenly over all expansion opport unities in the run. 94 // Distribute the run's total expansion evenly over all expansion opport unities in the run.
95 if (m_expansion) { 95 if (m_expansion) {
96 if (!isExpansionOpportunity && !m_isAfterExpansion) { 96 if (!isExpansionOpportunity && !m_isAfterExpansion) {
97 // Take the expansion opportunity before this ideograph. 97 // Take the expansion opportunity before this ideograph.
98 m_expansion -= m_expansionPerOpportunity; 98 m_expansion -= m_expansionPerOpportunity;
99 m_runWidthSoFar += m_expansionPerOpportunity; 99 m_runWidthSoFar += m_expansionPerOpportunity;
100 } 100 }
101 if (m_textRun.allowsTrailingExpansion() 101 if (m_textRun.allowsTrailingExpansion()
102 || (m_textRun.ltr() && charData.characterOffset + charData.clust erLength < static_cast<size_t>(m_textRun.length())) 102 || (m_textRun.ltr() && charData.characterOffset + charData.clust erLength < static_cast<size_t>(m_textRun.length()))
103 || (m_textRun.rtl() && charData.characterOffset)) { 103 || (m_textRun.rtl() && charData.characterOffset)) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 float initialWidth = m_runWidthSoFar; 218 float initialWidth = m_runWidthSoFar;
219 219
220 if (!advance(m_currentCharacter + 1)) 220 if (!advance(m_currentCharacter + 1))
221 return false; 221 return false;
222 222
223 width = m_runWidthSoFar - initialWidth; 223 width = m_runWidthSoFar - initialWidth;
224 return true; 224 return true;
225 } 225 }
226 226
227 } // namespace blink 227 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | third_party/WebKit/Source/platform/text/TextRun.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698