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 * 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 19 matching lines...) Expand all Loading... |
30 #include "core/layout/LayoutTheme.h" | 30 #include "core/layout/LayoutTheme.h" |
31 #include "core/layout/LayoutView.h" | 31 #include "core/layout/LayoutView.h" |
32 #include "core/layout/TextAutosizer.h" | 32 #include "core/layout/TextAutosizer.h" |
33 #include "platform/FontFamilyNames.h" | 33 #include "platform/FontFamilyNames.h" |
34 #include "platform/fonts/FontDescription.h" | 34 #include "platform/fonts/FontDescription.h" |
35 #include "platform/text/LocaleToScriptMapping.h" | 35 #include "platform/text/LocaleToScriptMapping.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 FontBuilder::FontBuilder(const Document& document) | 39 FontBuilder::FontBuilder(const Document& document) |
40 : m_document(document) | 40 : m_document(&document) |
41 , m_flags(0) | 41 , m_flags(0) |
42 { | 42 { |
43 ASSERT(document.frame()); | 43 ASSERT(document.frame()); |
44 } | 44 } |
45 | 45 |
46 void FontBuilder::setInitial(float effectiveZoom) | 46 void FontBuilder::setInitial(float effectiveZoom) |
47 { | 47 { |
48 ASSERT(m_document.settings()); | 48 ASSERT(m_document->settings()); |
49 if (!m_document.settings()) | 49 if (!m_document->settings()) |
50 return; | 50 return; |
51 | 51 |
52 setFamilyDescription(m_fontDescription, FontBuilder::initialFamilyDescriptio
n()); | 52 setFamilyDescription(m_fontDescription, FontBuilder::initialFamilyDescriptio
n()); |
53 setSize(m_fontDescription, FontBuilder::initialSize()); | 53 setSize(m_fontDescription, FontBuilder::initialSize()); |
54 } | 54 } |
55 | 55 |
56 void FontBuilder::didChangeEffectiveZoom() | 56 void FontBuilder::didChangeEffectiveZoom() |
57 { | 57 { |
58 set(PropertySetFlag::EffectiveZoom); | 58 set(PropertySetFlag::EffectiveZoom); |
59 } | 59 } |
(...skipping 10 matching lines...) Expand all Loading... |
70 | 70 |
71 FontFamily FontBuilder::standardFontFamily() const | 71 FontFamily FontBuilder::standardFontFamily() const |
72 { | 72 { |
73 FontFamily family; | 73 FontFamily family; |
74 family.setFamily(standardFontFamilyName()); | 74 family.setFamily(standardFontFamilyName()); |
75 return family; | 75 return family; |
76 } | 76 } |
77 | 77 |
78 AtomicString FontBuilder::standardFontFamilyName() const | 78 AtomicString FontBuilder::standardFontFamilyName() const |
79 { | 79 { |
80 Settings* settings = m_document.settings(); | 80 Settings* settings = m_document->settings(); |
81 if (settings) | 81 if (settings) |
82 return settings->genericFontFamilySettings().standard(); | 82 return settings->genericFontFamilySettings().standard(); |
83 return AtomicString(); | 83 return AtomicString(); |
84 } | 84 } |
85 | 85 |
86 AtomicString FontBuilder::genericFontFamilyName(FontDescription::GenericFamilyTy
pe genericFamily) const | 86 AtomicString FontBuilder::genericFontFamilyName(FontDescription::GenericFamilyTy
pe genericFamily) const |
87 { | 87 { |
88 switch (genericFamily) { | 88 switch (genericFamily) { |
89 default: | 89 default: |
90 ASSERT_NOT_REACHED(); | 90 ASSERT_NOT_REACHED(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 fontDescription.setKeywordSize(size.keyword); | 221 fontDescription.setKeywordSize(size.keyword); |
222 fontDescription.setSpecifiedSize(specifiedSize); | 222 fontDescription.setSpecifiedSize(specifiedSize); |
223 fontDescription.setIsAbsoluteSize(size.isAbsolute); | 223 fontDescription.setIsAbsoluteSize(size.isAbsolute); |
224 } | 224 } |
225 | 225 |
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, fo
ntDescription.isAbsoluteSize(), specifiedSize); |
234 } | 234 } |
235 | 235 |
236 static FontOrientation fontOrientation(const ComputedStyle& 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; |
(...skipping 30 matching lines...) Expand all Loading... |
274 if (newDescription.genericFamily() != FontDescription::MonospaceFamily | 274 if (newDescription.genericFamily() != FontDescription::MonospaceFamily |
275 && oldDescription.genericFamily() != FontDescription::MonospaceFamily) | 275 && oldDescription.genericFamily() != FontDescription::MonospaceFamily) |
276 return; | 276 return; |
277 | 277 |
278 // We know the parent is monospace or the child is monospace, and that font | 278 // We know the parent is monospace or the child is monospace, and that font |
279 // size was unspecified. We want to scale our font size as appropriate. | 279 // size was unspecified. We want to scale our font size as appropriate. |
280 // If the font uses a keyword size, then we refetch from the table rather th
an | 280 // If the font uses a keyword size, then we refetch from the table rather th
an |
281 // multiplying by our scale factor. | 281 // multiplying by our scale factor. |
282 float size; | 282 float size; |
283 if (newDescription.keywordSize()) { | 283 if (newDescription.keywordSize()) { |
284 size = FontSize::fontSizeForKeyword(&m_document, newDescription.keywordS
ize(), newDescription.isMonospace()); | 284 size = FontSize::fontSizeForKeyword(m_document, newDescription.keywordSi
ze(), newDescription.isMonospace()); |
285 } else { | 285 } else { |
286 Settings* settings = m_document.settings(); | 286 Settings* settings = m_document->settings(); |
287 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() &
& settings->defaultFontSize()) | 287 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() &
& settings->defaultFontSize()) |
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.isMonospace() ? | 290 size = oldDescription.isMonospace() ? |
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 Co
mputedStyle& 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.isMonospace()); | 303 specifiedSize = FontSize::fontSizeForKeyword(m_document, fontDescription
.keywordSize(), fontDescription.isMonospace()); |
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 Com
putedStyle& 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) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |