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

Side by Side Diff: sky/engine/core/css/resolver/FontBuilder.cpp

Issue 711203002: Remove zoom() and effectiveZoom(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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) 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 fontDescription.setGenericFamily(FontDescription::StandardFamily); 84 fontDescription.setGenericFamily(FontDescription::StandardFamily);
85 const AtomicString& standardFontFamily = document->settings()->genericFontFa milySettings().standard(); 85 const AtomicString& standardFontFamily = document->settings()->genericFontFa milySettings().standard();
86 if (standardFontFamily.isEmpty()) 86 if (standardFontFamily.isEmpty())
87 return; 87 return;
88 88
89 fontDescription.firstFamily().setFamily(standardFontFamily); 89 fontDescription.firstFamily().setFamily(standardFontFamily);
90 // FIXME: Why is this needed here? 90 // FIXME: Why is this needed here?
91 fontDescription.firstFamily().appendFamily(nullptr); 91 fontDescription.firstFamily().appendFamily(nullptr);
92 } 92 }
93 93
94 void FontBuilder::setInitial(float effectiveZoom) 94 void FontBuilder::setInitial()
95 { 95 {
96 ASSERT(m_document && m_document->settings()); 96 ASSERT(m_document && m_document->settings());
97 if (!m_document || !m_document->settings()) 97 if (!m_document || !m_document->settings())
98 return; 98 return;
99 99
100 FontDescriptionChangeScope scope(this); 100 FontDescriptionChangeScope scope(this);
101 101
102 scope.reset(); 102 scope.reset();
103 setFontFamilyToStandard(scope.fontDescription(), m_document); 103 setFontFamilyToStandard(scope.fontDescription(), m_document);
104 scope.fontDescription().setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1) ; 104 scope.fontDescription().setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1) ;
105 setSize(scope.fontDescription(), effectiveZoom, FontSize::fontSizeForKeyword (m_document, CSSValueMedium, NonFixedPitchFont)); 105 setSize(scope.fontDescription(), FontSize::fontSizeForKeyword(m_document, CS SValueMedium, NonFixedPitchFont));
106 } 106 }
107 107
108 void FontBuilder::inheritFrom(const FontDescription& fontDescription) 108 void FontBuilder::inheritFrom(const FontDescription& fontDescription)
109 { 109 {
110 FontDescriptionChangeScope scope(this); 110 FontDescriptionChangeScope scope(this);
111 111
112 scope.set(fontDescription); 112 scope.set(fontDescription);
113 } 113 }
114 114
115 void FontBuilder::didChangeFontParameters(bool changed) 115 void FontBuilder::didChangeFontParameters(bool changed)
116 { 116 {
117 m_fontDirty |= changed; 117 m_fontDirty |= changed;
118 } 118 }
119 119
120 void FontBuilder::fromSystemFont(CSSValueID valueId, float effectiveZoom) 120 void FontBuilder::fromSystemFont(CSSValueID valueId)
121 { 121 {
122 FontDescriptionChangeScope scope(this); 122 FontDescriptionChangeScope scope(this);
123 123
124 FontDescription fontDescription; 124 FontDescription fontDescription;
125 RenderTheme::theme().systemFont(valueId, fontDescription); 125 RenderTheme::theme().systemFont(valueId, fontDescription);
126 126
127 // Double-check and see if the theme did anything. If not, don't bother upda ting the font. 127 // Double-check and see if the theme did anything. If not, don't bother upda ting the font.
128 if (!fontDescription.isAbsoluteSize()) 128 if (!fontDescription.isAbsoluteSize())
129 return; 129 return;
130 130
131 // Make sure the rendering mode and printer font settings are updated. 131 // Make sure the rendering mode and printer font settings are updated.
132 const Settings* settings = m_document->settings(); 132 const Settings* settings = m_document->settings();
133 ASSERT(settings); // If we're doing style resolution, this document should a lways be in a frame and thus have settings 133 ASSERT(settings); // If we're doing style resolution, this document should a lways be in a frame and thus have settings
134 if (!settings) 134 if (!settings)
135 return; 135 return;
136 136
137 // Handle the zoom factor. 137 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip tion, fontDescription.specifiedSize()));
138 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip tion, effectiveZoom, fontDescription.specifiedSize()));
139 scope.set(fontDescription); 138 scope.set(fontDescription);
140 } 139 }
141 140
142 void FontBuilder::setFontFamilyInitial() 141 void FontBuilder::setFontFamilyInitial()
143 { 142 {
144 FontDescriptionChangeScope scope(this); 143 FontDescriptionChangeScope scope(this);
145 144
146 setFontFamilyToStandard(scope.fontDescription(), m_document); 145 setFontFamilyToStandard(scope.fontDescription(), m_document);
147 } 146 }
148 147
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 321
323 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize && (value ID == CSSValueLarger || valueID == CSSValueSmaller)); 322 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize && (value ID == CSSValueLarger || valueID == CSSValueSmaller));
324 } else { 323 } else {
325 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize || !(prim itiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); 324 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize || !(prim itiveValue->isPercentage() || primitiveValue->isFontRelativeLength()));
326 if (primitiveValue->isPercentage()) { 325 if (primitiveValue->isPercentage()) {
327 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; 326 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f;
328 } else { 327 } else {
329 // If we have viewport units the conversion will mark the parent sty le as having viewport units. 328 // If we have viewport units the conversion will mark the parent sty le as having viewport units.
330 bool parentHasViewportUnits = parentStyle->hasViewportUnits(); 329 bool parentHasViewportUnits = parentStyle->hasViewportUnits();
331 parentStyle->setHasViewportUnits(false); 330 parentStyle->setHasViewportUnits(false);
332 CSSToLengthConversionData conversionData(parentStyle, rootElementSty le, m_document->renderView(), 1.0f, true); 331 CSSToLengthConversionData conversionData(parentStyle, rootElementSty le, m_document->renderView(), true);
333 if (primitiveValue->isLength()) 332 if (primitiveValue->isLength())
334 size = primitiveValue->computeLength<float>(conversionData); 333 size = primitiveValue->computeLength<float>(conversionData);
335 else if (primitiveValue->isCalculatedPercentageWithLength()) 334 else if (primitiveValue->isCalculatedPercentageWithLength())
336 size = primitiveValue->cssCalcValue()->toCalcValue(conversionDat a)->evaluate(parentSize); 335 size = primitiveValue->cssCalcValue()->toCalcValue(conversionDat a)->evaluate(parentSize);
337 else 336 else
338 ASSERT_NOT_REACHED(); 337 ASSERT_NOT_REACHED();
339 m_fontSizehasViewportUnits = parentStyle->hasViewportUnits(); 338 m_fontSizehasViewportUnits = parentStyle->hasViewportUnits();
340 parentStyle->setHasViewportUnits(parentHasViewportUnits); 339 parentStyle->setHasViewportUnits(parentHasViewportUnits);
341 } 340 }
342 } 341 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 scope.fontDescription().setFontSmoothing(foontSmoothingMode); 415 scope.fontDescription().setFontSmoothing(foontSmoothingMode);
417 } 416 }
418 417
419 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) 418 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings)
420 { 419 {
421 FontDescriptionChangeScope scope(this); 420 FontDescriptionChangeScope scope(this);
422 421
423 scope.fontDescription().setFeatureSettings(settings); 422 scope.fontDescription().setFeatureSettings(settings);
424 } 423 }
425 424
426 void FontBuilder::setSize(FontDescription& fontDescription, float effectiveZoom, float size) 425 void FontBuilder::setSize(FontDescription& fontDescription, float size)
427 { 426 {
428 fontDescription.setSpecifiedSize(size); 427 fontDescription.setSpecifiedSize(size);
429 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip tion, effectiveZoom, size)); 428 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip tion, size));
430 } 429 }
431 430
432 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize) 431 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float specifiedSize)
433 { 432 {
434 float zoomFactor = effectiveZoom; 433 return FontSize::getComputedSizeFromSpecifiedSize(m_document, fontDescriptio n.isAbsoluteSize(), specifiedSize);
435 // FIXME: Why is this here!!!!?!
436 if (LocalFrame* frame = m_document->frame())
437 zoomFactor *= frame->textZoomFactor();
438
439 return FontSize::getComputedSizeFromSpecifiedSize(m_document, zoomFactor, fo ntDescription.isAbsoluteSize(), specifiedSize);
440 } 434 }
441 435
442 static void getFontAndGlyphOrientation(const RenderStyle* style, FontOrientation & fontOrientation, NonCJKGlyphOrientation& glyphOrientation) 436 static void getFontAndGlyphOrientation(const RenderStyle* style, FontOrientation & fontOrientation, NonCJKGlyphOrientation& glyphOrientation)
443 { 437 {
444 // FIXME(sky): Remove this function now that we don't have writing modes. 438 // FIXME(sky): Remove this function now that we don't have writing modes.
445 fontOrientation = Horizontal; 439 fontOrientation = Horizontal;
446 glyphOrientation = NonCJKGlyphOrientationVerticalRight; 440 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
447 } 441 }
448 442
449 void FontBuilder::checkForOrientationChange(RenderStyle* style) 443 void FontBuilder::checkForOrientationChange(RenderStyle* style)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } else { 481 } else {
488 Settings* settings = m_document->settings(); 482 Settings* settings = m_document->settings();
489 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() & & settings->defaultFontSize()) 483 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() & & settings->defaultFontSize())
490 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d efaultFontSize() 484 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d efaultFontSize()
491 : 1; 485 : 1;
492 size = parentFontDescription.fixedPitchFontType() == FixedPitchFont ? 486 size = parentFontDescription.fixedPitchFontType() == FixedPitchFont ?
493 scope.fontDescription().specifiedSize() / fixedScaleFactor : 487 scope.fontDescription().specifiedSize() / fixedScaleFactor :
494 scope.fontDescription().specifiedSize() * fixedScaleFactor; 488 scope.fontDescription().specifiedSize() * fixedScaleFactor;
495 } 489 }
496 490
497 setSize(scope.fontDescription(), style->effectiveZoom(), size); 491 setSize(scope.fontDescription(), size);
498 } 492 }
499 493
500 void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* pare ntStyle) 494 void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* pare ntStyle)
501 { 495 {
502 FontDescriptionChangeScope scope(this); 496 FontDescriptionChangeScope scope(this);
503 497
504 float computedSize = getComputedSizeFromSpecifiedSize(scope.fontDescription( ), style->effectiveZoom(), scope.fontDescription().specifiedSize()); 498 float computedSize = getComputedSizeFromSpecifiedSize(scope.fontDescription( ), scope.fontDescription().specifiedSize());
505 scope.fontDescription().setComputedSize(computedSize); 499 scope.fontDescription().setComputedSize(computedSize);
506 } 500 }
507 501
508 // FIXME: style param should come first 502 // FIXME: style param should come first
509 void FontBuilder::createFont(PassRefPtr<FontSelector> fontSelector, const Render Style* parentStyle, RenderStyle* style) 503 void FontBuilder::createFont(PassRefPtr<FontSelector> fontSelector, const Render Style* parentStyle, RenderStyle* style)
510 { 504 {
511 if (!m_fontDirty) 505 if (!m_fontDirty)
512 return; 506 return;
513 507
514 updateComputedSize(style, parentStyle); 508 updateComputedSize(style, parentStyle);
515 checkForGenericFamilyChange(style, parentStyle); 509 checkForGenericFamilyChange(style, parentStyle);
516 checkForOrientationChange(style); 510 checkForOrientationChange(style);
517 style->font().update(fontSelector); 511 style->font().update(fontSelector);
518 m_fontDirty = false; 512 m_fontDirty = false;
519 } 513 }
520 514
521 void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, R enderStyle* documentStyle) 515 void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, R enderStyle* documentStyle)
522 { 516 {
523 FontDescription fontDescription = FontDescription(); 517 FontDescription fontDescription = FontDescription();
524 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle-> locale())); 518 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle-> locale()));
525 519
526 setFontFamilyToStandard(fontDescription, m_document); 520 setFontFamilyToStandard(fontDescription, m_document);
527 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); 521 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
528 int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, NonFixed PitchFont); 522 int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, NonFixed PitchFont);
529 fontDescription.setSpecifiedSize(size); 523 fontDescription.setSpecifiedSize(size);
530 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip tion, documentStyle->effectiveZoom(), size)); 524 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip tion, size));
531 525
532 FontOrientation fontOrientation; 526 FontOrientation fontOrientation;
533 NonCJKGlyphOrientation glyphOrientation; 527 NonCJKGlyphOrientation glyphOrientation;
534 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ; 528 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ;
535 fontDescription.setOrientation(fontOrientation); 529 fontDescription.setOrientation(fontOrientation);
536 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); 530 fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
537 documentStyle->setFontDescription(fontDescription); 531 documentStyle->setFontDescription(fontDescription);
538 documentStyle->font().update(fontSelector); 532 documentStyle->font().update(fontSelector);
539 } 533 }
540 534
541 } 535 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/FontBuilder.h ('k') | sky/engine/core/css/resolver/StyleBuilderConverter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698