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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/resolver/FontBuilder.h ('k') | Source/core/css/resolver/FontBuilderTest.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 * Copyright (C) 2015 Collabora Ltd. All rights reserved. 5 * Copyright (C) 2015 Collabora Ltd. 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize) 226 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize)
227 { 227 {
228 float zoomFactor = effectiveZoom; 228 float zoomFactor = effectiveZoom;
229 // FIXME: Why is this here!!!!?! 229 // FIXME: Why is this here!!!!?!
230 if (LocalFrame* frame = m_document.frame()) 230 if (LocalFrame* frame = m_document.frame())
231 zoomFactor *= frame->textZoomFactor(); 231 zoomFactor *= frame->textZoomFactor();
232 232
233 return FontSize::getComputedSizeFromSpecifiedSize(&m_document, zoomFactor, f ontDescription.isAbsoluteSize(), specifiedSize); 233 return FontSize::getComputedSizeFromSpecifiedSize(&m_document, zoomFactor, f ontDescription.isAbsoluteSize(), specifiedSize);
234 } 234 }
235 235
236 static FontOrientation fontOrientation(const LayoutStyle& style) 236 static FontOrientation fontOrientation(const ComputedStyle& style)
237 { 237 {
238 if (style.isHorizontalWritingMode()) 238 if (style.isHorizontalWritingMode())
239 return FontOrientation::Horizontal; 239 return FontOrientation::Horizontal;
240 240
241 switch (style.textOrientation()) { 241 switch (style.textOrientation()) {
242 case TextOrientationVerticalRight: 242 case TextOrientationVerticalRight:
243 return FontOrientation::VerticalMixed; 243 return FontOrientation::VerticalMixed;
244 case TextOrientationUpright: 244 case TextOrientationUpright:
245 return FontOrientation::VerticalUpright; 245 return FontOrientation::VerticalUpright;
246 case TextOrientationSideways: 246 case TextOrientationSideways:
247 if (style.writingMode() == LeftToRightWritingMode) { 247 if (style.writingMode() == LeftToRightWritingMode) {
248 // FIXME: This should map to sideways-left, which is not supported y et. 248 // FIXME: This should map to sideways-left, which is not supported y et.
249 return FontOrientation::VerticalRotated; 249 return FontOrientation::VerticalRotated;
250 } 250 }
251 return FontOrientation::VerticalRotated; 251 return FontOrientation::VerticalRotated;
252 case TextOrientationSidewaysRight: 252 case TextOrientationSidewaysRight:
253 return FontOrientation::VerticalRotated; 253 return FontOrientation::VerticalRotated;
254 default: 254 default:
255 ASSERT_NOT_REACHED(); 255 ASSERT_NOT_REACHED();
256 return FontOrientation::VerticalMixed; 256 return FontOrientation::VerticalMixed;
257 } 257 }
258 } 258 }
259 259
260 void FontBuilder::updateOrientation(FontDescription& description, const LayoutSt yle& style) 260 void FontBuilder::updateOrientation(FontDescription& description, const Computed Style& style)
261 { 261 {
262 description.setOrientation(fontOrientation(style)); 262 description.setOrientation(fontOrientation(style));
263 } 263 }
264 264
265 void FontBuilder::checkForGenericFamilyChange(const FontDescription& oldDescript ion, FontDescription& newDescription) 265 void FontBuilder::checkForGenericFamilyChange(const FontDescription& oldDescript ion, FontDescription& newDescription)
266 { 266 {
267 if (newDescription.isAbsoluteSize()) 267 if (newDescription.isAbsoluteSize())
268 return; 268 return;
269 269
270 if (newDescription.fixedPitchFontType() == oldDescription.fixedPitchFontType ()) 270 if (newDescription.fixedPitchFontType() == oldDescription.fixedPitchFontType ())
(...skipping 17 matching lines...) Expand all
288 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d efaultFontSize() 288 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d efaultFontSize()
289 : 1; 289 : 1;
290 size = oldDescription.fixedPitchFontType() == FixedPitchFont ? 290 size = oldDescription.fixedPitchFontType() == FixedPitchFont ?
291 newDescription.specifiedSize() / fixedScaleFactor : 291 newDescription.specifiedSize() / fixedScaleFactor :
292 newDescription.specifiedSize() * fixedScaleFactor; 292 newDescription.specifiedSize() * fixedScaleFactor;
293 } 293 }
294 294
295 newDescription.setSpecifiedSize(size); 295 newDescription.setSpecifiedSize(size);
296 } 296 }
297 297
298 void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, const La youtStyle& style) 298 void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, const Co mputedStyle& style)
299 { 299 {
300 float specifiedSize = fontDescription.specifiedSize(); 300 float specifiedSize = fontDescription.specifiedSize();
301 301
302 if (!specifiedSize && fontDescription.keywordSize()) 302 if (!specifiedSize && fontDescription.keywordSize())
303 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio n.keywordSize(), fontDescription.fixedPitchFontType()); 303 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio n.keywordSize(), fontDescription.fixedPitchFontType());
304 304
305 fontDescription.setSpecifiedSize(specifiedSize); 305 fontDescription.setSpecifiedSize(specifiedSize);
306 306
307 checkForGenericFamilyChange(style.fontDescription(), fontDescription); 307 checkForGenericFamilyChange(style.fontDescription(), fontDescription);
308 } 308 }
309 309
310 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Lay outStyle& style, FontSelector* fontSelector) 310 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Com putedStyle& style, FontSelector* fontSelector)
311 { 311 {
312 const float specifiedSize = fontDescription.specifiedSize(); 312 const float specifiedSize = fontDescription.specifiedSize();
313 if (!fontDescription.hasSizeAdjust() || !specifiedSize) 313 if (!fontDescription.hasSizeAdjust() || !specifiedSize)
314 return; 314 return;
315 315
316 // We need to create a temporal Font to get xHeight of a primary font. 316 // We need to create a temporal Font to get xHeight of a primary font.
317 // The aspect value is based on the xHeight of the font for the computed fon t size, 317 // The aspect value is based on the xHeight of the font for the computed fon t size,
318 // so we need to reset the adjustedSize to computedSize. See FontDescription ::effectiveFontSize. 318 // so we need to reset the adjustedSize to computedSize. See FontDescription ::effectiveFontSize.
319 fontDescription.setAdjustedSize(fontDescription.computedSize()); 319 fontDescription.setAdjustedSize(fontDescription.computedSize());
320 320
321 Font font(fontDescription); 321 Font font(fontDescription);
322 font.update(fontSelector); 322 font.update(fontSelector);
323 if (!font.fontMetrics().hasXHeight()) 323 if (!font.fontMetrics().hasXHeight())
324 return; 324 return;
325 325
326 const float sizeAdjust = fontDescription.sizeAdjust(); 326 const float sizeAdjust = fontDescription.sizeAdjust();
327 float aspectValue = font.fontMetrics().xHeight() / specifiedSize; 327 float aspectValue = font.fontMetrics().xHeight() / specifiedSize;
328 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; 328 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
329 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec tiveZoom(), adjustedSize); 329 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec tiveZoom(), adjustedSize);
330 330
331 float multiplier = style.textAutosizingMultiplier(); 331 float multiplier = style.textAutosizingMultiplier();
332 if (multiplier > 1) 332 if (multiplier > 1)
333 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul tiplier); 333 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul tiplier);
334 fontDescription.setAdjustedSize(adjustedSize); 334 fontDescription.setAdjustedSize(adjustedSize);
335 } 335 }
336 336
337 void FontBuilder::updateComputedSize(FontDescription& fontDescription, const Lay outStyle& style) 337 void FontBuilder::updateComputedSize(FontDescription& fontDescription, const Com putedStyle& style)
338 { 338 {
339 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style .effectiveZoom(), fontDescription.specifiedSize()); 339 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style .effectiveZoom(), fontDescription.specifiedSize());
340 float multiplier = style.textAutosizingMultiplier(); 340 float multiplier = style.textAutosizingMultiplier();
341 if (multiplier > 1) 341 if (multiplier > 1)
342 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul tiplier); 342 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul tiplier);
343 fontDescription.setComputedSize(computedSize); 343 fontDescription.setComputedSize(computedSize);
344 } 344 }
345 345
346 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, LayoutStyle& style) 346 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, ComputedStyle& style)
347 { 347 {
348 if (!m_flags) 348 if (!m_flags)
349 return; 349 return;
350 350
351 FontDescription description = style.fontDescription(); 351 FontDescription description = style.fontDescription();
352 352
353 if (isSet(PropertySetFlag::Family)) { 353 if (isSet(PropertySetFlag::Family)) {
354 description.setGenericFamily(m_fontDescription.genericFamily()); 354 description.setGenericFamily(m_fontDescription.genericFamily());
355 description.setFamily(m_fontDescription.family()); 355 description.setFamily(m_fontDescription.family());
356 } 356 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 388
389 updateSpecifiedSize(description, style); 389 updateSpecifiedSize(description, style);
390 updateComputedSize(description, style); 390 updateComputedSize(description, style);
391 updateAdjustedSize(description, style, fontSelector.get()); 391 updateAdjustedSize(description, style, fontSelector.get());
392 392
393 style.setFontDescription(description); 393 style.setFontDescription(description);
394 style.font().update(fontSelector); 394 style.font().update(fontSelector);
395 m_flags = 0; 395 m_flags = 0;
396 } 396 }
397 397
398 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon tSelector, LayoutStyle& documentStyle) 398 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon tSelector, ComputedStyle& documentStyle)
399 { 399 {
400 FontDescription fontDescription = FontDescription(); 400 FontDescription fontDescription = FontDescription();
401 fontDescription.setLocale(documentStyle.locale()); 401 fontDescription.setLocale(documentStyle.locale());
402 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle.l ocale())); 402 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle.l ocale()));
403 403
404 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription( )); 404 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription( ));
405 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false)); 405 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false));
406 updateSpecifiedSize(fontDescription, documentStyle); 406 updateSpecifiedSize(fontDescription, documentStyle);
407 updateComputedSize(fontDescription, documentStyle); 407 updateComputedSize(fontDescription, documentStyle);
408 408
409 updateOrientation(fontDescription, documentStyle); 409 updateOrientation(fontDescription, documentStyle);
410 documentStyle.setFontDescription(fontDescription); 410 documentStyle.setFontDescription(fontDescription);
411 documentStyle.font().update(fontSelector); 411 documentStyle.font().update(fontSelector);
412 } 412 }
413 413
414 } 414 }
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FontBuilder.h ('k') | Source/core/css/resolver/FontBuilderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698