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

Side by Side Diff: Source/core/css/resolver/FontBuilder.cpp

Issue 712333004: Create the document font using normal FontBuilder calls. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Recreate patch on new master. Created 5 years, 10 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/core/css/resolver/FontBuilder.h ('k') | Source/core/css/resolver/StyleResolver.cpp » ('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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 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 30 matching lines...) Expand all
41 { 41 {
42 ASSERT(document.frame()); 42 ASSERT(document.frame());
43 } 43 }
44 44
45 void FontBuilder::setInitial(float effectiveZoom) 45 void FontBuilder::setInitial(float effectiveZoom)
46 { 46 {
47 ASSERT(m_document.settings()); 47 ASSERT(m_document.settings());
48 if (!m_document.settings()) 48 if (!m_document.settings())
49 return; 49 return;
50 50
51 setFamilyDescription(m_fontDescription, FontBuilder::initialFamilyDescriptio n()); 51 setFamilyDescription(FontBuilder::initialFamilyDescription());
52 setSize(m_fontDescription, FontBuilder::initialSize()); 52 setSize(FontBuilder::initialSize());
53 } 53 }
54 54
55 void FontBuilder::didChangeEffectiveZoom() 55 void FontBuilder::didChangeEffectiveZoom()
56 { 56 {
57 set(PropertySetFlag::EffectiveZoom); 57 set(PropertySetFlag::EffectiveZoom);
58 } 58 }
59 59
60 void FontBuilder::didChangeTextOrientation() 60 void FontBuilder::didChangeTextOrientation()
61 { 61 {
62 set(PropertySetFlag::TextOrientation); 62 set(PropertySetFlag::TextOrientation);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return FontFamilyNames::webkit_cursive; 101 return FontFamilyNames::webkit_cursive;
102 case FontDescription::FantasyFamily: 102 case FontDescription::FantasyFamily:
103 return FontFamilyNames::webkit_fantasy; 103 return FontFamilyNames::webkit_fantasy;
104 case FontDescription::PictographFamily: 104 case FontDescription::PictographFamily:
105 return FontFamilyNames::webkit_pictograph; 105 return FontFamilyNames::webkit_pictograph;
106 } 106 }
107 } 107 }
108 108
109 void FontBuilder::setFamilyDescription(const FontDescription::FamilyDescription& familyDescription) 109 void FontBuilder::setFamilyDescription(const FontDescription::FamilyDescription& familyDescription)
110 { 110 {
111 setFamilyDescription(m_fontDescription, familyDescription); 111 set(PropertySetFlag::Family);
112
113 bool isInitial = familyDescription.genericFamily == FontDescription::Standar dFamily && familyDescription.family.familyIsEmpty();
114
115 m_fontDescription.setGenericFamily(familyDescription.genericFamily);
116 m_fontDescription.setFamily(isInitial ? standardFontFamily() : familyDescrip tion.family);
112 } 117 }
113 118
114 void FontBuilder::setWeight(FontWeight fontWeight) 119 void FontBuilder::setWeight(FontWeight fontWeight)
115 { 120 {
116 set(PropertySetFlag::Weight); 121 set(PropertySetFlag::Weight);
117 122
118 m_fontDescription.setWeight(fontWeight); 123 m_fontDescription.setWeight(fontWeight);
119 } 124 }
120 125
121 void FontBuilder::setSize(const FontDescription::Size& size) 126 void FontBuilder::setSize(const FontDescription::Size& size)
122 { 127 {
123 setSize(m_fontDescription, size); 128 float specifiedSize = size.value;
129
130 if (specifiedSize < 0)
131 return;
132
133 set(PropertySetFlag::Size);
134
135 // Overly large font sizes will cause crashes on some platforms (such as Win dows).
136 // Cap font size here to make sure that doesn't happen.
137 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize);
138
139 m_fontDescription.setKeywordSize(size.keyword);
140 m_fontDescription.setSpecifiedSize(specifiedSize);
141 m_fontDescription.setIsAbsoluteSize(size.isAbsolute);
124 } 142 }
125 143
126 void FontBuilder::setStretch(FontStretch fontStretch) 144 void FontBuilder::setStretch(FontStretch fontStretch)
127 { 145 {
128 set(PropertySetFlag::Stretch); 146 set(PropertySetFlag::Stretch);
129 147
130 m_fontDescription.setStretch(fontStretch); 148 m_fontDescription.setStretch(fontStretch);
131 } 149 }
132 150
133 void FontBuilder::setScript(const String& locale) 151 void FontBuilder::setScript(const String& locale)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 m_fontDescription.setFontSmoothing(foontSmoothingMode); 198 m_fontDescription.setFontSmoothing(foontSmoothingMode);
181 } 199 }
182 200
183 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) 201 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings)
184 { 202 {
185 set(PropertySetFlag::FeatureSettings); 203 set(PropertySetFlag::FeatureSettings);
186 204
187 m_fontDescription.setFeatureSettings(settings); 205 m_fontDescription.setFeatureSettings(settings);
188 } 206 }
189 207
190 void FontBuilder::setFamilyDescription(FontDescription& fontDescription, const F ontDescription::FamilyDescription& familyDescription)
191 {
192 set(PropertySetFlag::Family);
193
194 bool isInitial = familyDescription.genericFamily == FontDescription::Standar dFamily && familyDescription.family.familyIsEmpty();
195
196 fontDescription.setGenericFamily(familyDescription.genericFamily);
197 fontDescription.setFamily(isInitial ? standardFontFamily() : familyDescripti on.family);
198 }
199
200 void FontBuilder::setSize(FontDescription& fontDescription, const FontDescriptio n::Size& size)
201 {
202 float specifiedSize = size.value;
203
204 if (specifiedSize < 0)
205 return;
206
207 set(PropertySetFlag::Size);
208
209 // Overly large font sizes will cause crashes on some platforms (such as Win dows).
210 // Cap font size here to make sure that doesn't happen.
211 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize);
212
213 fontDescription.setKeywordSize(size.keyword);
214 fontDescription.setSpecifiedSize(specifiedSize);
215 fontDescription.setIsAbsoluteSize(size.isAbsolute);
216 }
217
218 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize) 208 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize)
219 { 209 {
220 float zoomFactor = effectiveZoom; 210 float zoomFactor = effectiveZoom;
221 // FIXME: Why is this here!!!!?! 211 // FIXME: Why is this here!!!!?!
222 if (LocalFrame* frame = m_document.frame()) 212 if (LocalFrame* frame = m_document.frame())
223 zoomFactor *= frame->textZoomFactor(); 213 zoomFactor *= frame->textZoomFactor();
224 214
225 return FontSize::getComputedSizeFromSpecifiedSize(&m_document, zoomFactor, f ontDescription.isAbsoluteSize(), specifiedSize); 215 return FontSize::getComputedSizeFromSpecifiedSize(&m_document, zoomFactor, f ontDescription.isAbsoluteSize(), specifiedSize);
226 } 216 }
227 217
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 updateOrientation(description, style); 360 updateOrientation(description, style);
371 361
372 updateSpecifiedSize(description, style); 362 updateSpecifiedSize(description, style);
373 updateComputedSize(description, style); 363 updateComputedSize(description, style);
374 364
375 style->setFontDescription(description); 365 style->setFontDescription(description);
376 style->font().update(fontSelector); 366 style->font().update(fontSelector);
377 m_flags = 0; 367 m_flags = 0;
378 } 368 }
379 369
380 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon tSelector, RenderStyle* documentStyle)
381 {
382 FontDescription fontDescription = FontDescription();
383 fontDescription.setLocale(documentStyle->locale());
384 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle-> locale()));
385
386 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription( ));
387 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false));
388 updateSpecifiedSize(fontDescription, documentStyle);
389 updateComputedSize(fontDescription, documentStyle);
390
391 FontOrientation fontOrientation;
392 NonCJKGlyphOrientation glyphOrientation;
393 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ;
394 fontDescription.setOrientation(fontOrientation);
395 fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
396 documentStyle->setFontDescription(fontDescription);
397 documentStyle->font().update(fontSelector);
398 } 370 }
399
400 }
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FontBuilder.h ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698