OLD | NEW |
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // All documents need to be in a frame (and thus have access to Settings) | 73 // All documents need to be in a frame (and thus have access to Settings) |
74 // for style-resolution to make sense. | 74 // for style-resolution to make sense. |
75 // Unfortunately SVG Animations currently violate this: crbug.com/260966 | 75 // Unfortunately SVG Animations currently violate this: crbug.com/260966 |
76 // ASSERT(m_document->frame()); | 76 // ASSERT(m_document->frame()); |
77 m_document = &document; | 77 m_document = &document; |
78 m_useSVGZoomRules = useSVGZoomRules; | 78 m_useSVGZoomRules = useSVGZoomRules; |
79 m_style = style; | 79 m_style = style; |
80 m_fontDirty = false; | 80 m_fontDirty = false; |
81 } | 81 } |
82 | 82 |
| 83 inline static void setFontFamilyToStandard(FontDescription& fontDescription, con
st Document* document) |
| 84 { |
| 85 if (!document || !document->settings()) |
| 86 return; |
| 87 |
| 88 fontDescription.setGenericFamily(FontDescription::StandardFamily); |
| 89 const AtomicString& standardFontFamily = document->settings()->genericFontFa
milySettings().standard(); |
| 90 if (standardFontFamily.isEmpty()) |
| 91 return; |
| 92 |
| 93 fontDescription.firstFamily().setFamily(standardFontFamily); |
| 94 // FIXME: Why is this needed here? |
| 95 fontDescription.firstFamily().appendFamily(nullptr); |
| 96 } |
| 97 |
83 void FontBuilder::setInitial(float effectiveZoom) | 98 void FontBuilder::setInitial(float effectiveZoom) |
84 { | 99 { |
85 ASSERT(m_document && m_document->settings()); | 100 ASSERT(m_document && m_document->settings()); |
86 if (!m_document || !m_document->settings()) | 101 if (!m_document || !m_document->settings()) |
87 return; | 102 return; |
88 | 103 |
89 FontDescriptionChangeScope scope(this); | 104 FontDescriptionChangeScope scope(this); |
90 | 105 |
91 scope.reset(); | 106 scope.reset(); |
92 scope.fontDescription().setGenericFamily(FontDescription::StandardFamily); | |
93 scope.fontDescription().setUsePrinterFont(m_document->printing()); | 107 scope.fontDescription().setUsePrinterFont(m_document->printing()); |
94 const AtomicString& standardFontFamily = m_document->settings()->genericFont
FamilySettings().standard(); | 108 setFontFamilyToStandard(scope.fontDescription(), m_document); |
95 if (!standardFontFamily.isEmpty()) { | |
96 scope.fontDescription().firstFamily().setFamily(standardFontFamily); | |
97 scope.fontDescription().firstFamily().appendFamily(nullptr); | |
98 } | |
99 scope.fontDescription().setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1)
; | 109 scope.fontDescription().setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1)
; |
100 setSize(scope.fontDescription(), effectiveZoom, FontSize::fontSizeForKeyword
(m_document, CSSValueMedium, false)); | 110 setSize(scope.fontDescription(), effectiveZoom, FontSize::fontSizeForKeyword
(m_document, CSSValueMedium, false)); |
101 } | 111 } |
102 | 112 |
103 void FontBuilder::inheritFrom(const FontDescription& fontDescription) | 113 void FontBuilder::inheritFrom(const FontDescription& fontDescription) |
104 { | 114 { |
105 FontDescriptionChangeScope scope(this); | 115 FontDescriptionChangeScope scope(this); |
106 | 116 |
107 scope.set(fontDescription); | 117 scope.set(fontDescription); |
108 } | 118 } |
(...skipping 23 matching lines...) Expand all Loading... |
132 | 142 |
133 // Handle the zoom factor. | 143 // Handle the zoom factor. |
134 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip
tion, effectiveZoom, fontDescription.specifiedSize())); | 144 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip
tion, effectiveZoom, fontDescription.specifiedSize())); |
135 scope.set(fontDescription); | 145 scope.set(fontDescription); |
136 } | 146 } |
137 | 147 |
138 void FontBuilder::setFontFamilyInitial() | 148 void FontBuilder::setFontFamilyInitial() |
139 { | 149 { |
140 FontDescriptionChangeScope scope(this); | 150 FontDescriptionChangeScope scope(this); |
141 | 151 |
142 scope.fontDescription().setGenericFamily(FontBuilder::initialGenericFamily()
); | 152 setFontFamilyToStandard(scope.fontDescription(), m_document); |
143 } | 153 } |
144 | 154 |
145 void FontBuilder::setFontFamilyInherit(const FontDescription& parentFontDescript
ion) | 155 void FontBuilder::setFontFamilyInherit(const FontDescription& parentFontDescript
ion) |
146 { | 156 { |
147 FontDescriptionChangeScope scope(this); | 157 FontDescriptionChangeScope scope(this); |
148 | 158 |
149 scope.fontDescription().setGenericFamily(parentFontDescription.genericFamily
()); | 159 scope.fontDescription().setGenericFamily(parentFontDescription.genericFamily
()); |
150 scope.fontDescription().setFamily(parentFontDescription.family()); | 160 scope.fontDescription().setFamily(parentFontDescription.family()); |
151 scope.fontDescription().setIsSpecifiedFont(parentFontDescription.isSpecified
Font()); | 161 scope.fontDescription().setIsSpecifiedFont(parentFontDescription.isSpecified
Font()); |
152 } | 162 } |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 checkForGenericFamilyChange(style, parentStyle); | 653 checkForGenericFamilyChange(style, parentStyle); |
644 checkForOrientationChange(style); | 654 checkForOrientationChange(style); |
645 style->font().update(fontSelector); | 655 style->font().update(fontSelector); |
646 m_fontDirty = false; | 656 m_fontDirty = false; |
647 } | 657 } |
648 | 658 |
649 void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, R
enderStyle* documentStyle) | 659 void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, R
enderStyle* documentStyle) |
650 { | 660 { |
651 FontDescription fontDescription = FontDescription(); | 661 FontDescription fontDescription = FontDescription(); |
652 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->
locale())); | 662 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->
locale())); |
653 if (Settings* settings = m_document->settings()) { | 663 fontDescription.setUsePrinterFont(m_document->printing()); |
654 fontDescription.setUsePrinterFont(m_document->printing()); | 664 |
655 const AtomicString& standardFont = settings->genericFontFamilySettings()
.standard(fontDescription.script()); | 665 setFontFamilyToStandard(fontDescription, m_document); |
656 if (!standardFont.isEmpty()) { | 666 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); |
657 fontDescription.setGenericFamily(FontDescription::StandardFamily); | 667 int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, false); |
658 fontDescription.firstFamily().setFamily(standardFont); | 668 fontDescription.setSpecifiedSize(size); |
659 fontDescription.firstFamily().appendFamily(nullptr); | 669 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescrip
tion, documentStyle->effectiveZoom(), size)); |
660 } | |
661 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); | |
662 int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, fals
e); | |
663 fontDescription.setSpecifiedSize(size); | |
664 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDes
cription, documentStyle->effectiveZoom(), size)); | |
665 } else { | |
666 fontDescription.setUsePrinterFont(m_document->printing()); | |
667 } | |
668 | 670 |
669 FontOrientation fontOrientation; | 671 FontOrientation fontOrientation; |
670 NonCJKGlyphOrientation glyphOrientation; | 672 NonCJKGlyphOrientation glyphOrientation; |
671 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; | 673 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; |
672 fontDescription.setOrientation(fontOrientation); | 674 fontDescription.setOrientation(fontOrientation); |
673 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 675 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); |
674 documentStyle->setFontDescription(fontDescription); | 676 documentStyle->setFontDescription(fontDescription); |
675 documentStyle->font().update(fontSelector); | 677 documentStyle->font().update(fontSelector); |
676 } | 678 } |
677 | 679 |
678 } | 680 } |
OLD | NEW |