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

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

Issue 715633006: Remove FontDescriptionChangeScope, and let FontBuilder partially apply values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix size/family ordering. Created 6 years 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 17 matching lines...) Expand all
28 #include "platform/fonts/FontDescription.h" 28 #include "platform/fonts/FontDescription.h"
29 #include "platform/heap/Handle.h" 29 #include "platform/heap/Handle.h"
30 #include "wtf/PassRefPtr.h" 30 #include "wtf/PassRefPtr.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 class CSSValue; 34 class CSSValue;
35 class FontSelector; 35 class FontSelector;
36 class RenderStyle; 36 class RenderStyle;
37 37
38 class FontDescriptionChangeScope;
39
40 class FontBuilder { 38 class FontBuilder {
41 STACK_ALLOCATED(); 39 STACK_ALLOCATED();
42 WTF_MAKE_NONCOPYABLE(FontBuilder); 40 WTF_MAKE_NONCOPYABLE(FontBuilder);
43 public: 41 public:
44 FontBuilder(const Document&); 42 FontBuilder(const Document&);
45 43
46 void setFontDescription(const FontDescription& fd) { m_fontDescription = fd; }
47 const FontDescription& fontDescription() const { return m_fontDescription; }
48
49 void setInitial(float effectiveZoom); 44 void setInitial(float effectiveZoom);
50 45
51 void didChangeFontParameters(bool); 46 void didChangeEffectiveZoom(bool);
52 47 void didChangeTextOrientation(bool);
53 void inheritFrom(const FontDescription&); 48 void didChangeWritingMode(bool);
rune 2015/02/03 12:25:40 I would have removed the bool parameters and check
andersr 2015/02/03 15:35:08 Done.
54 49
55 FontFamily standardFontFamily() const; 50 FontFamily standardFontFamily() const;
56 AtomicString standardFontFamilyName() const; 51 AtomicString standardFontFamilyName() const;
57 AtomicString genericFontFamilyName(FontDescription::GenericFamilyType) const ; 52 AtomicString genericFontFamilyName(FontDescription::GenericFamilyType) const ;
58 53
59 void setWeight(FontWeight); 54 void setWeight(FontWeight);
60 void setSize(const FontDescription::Size&); 55 void setSize(const FontDescription::Size&);
61 void setStretch(FontStretch); 56 void setStretch(FontStretch);
62 void setFamilyDescription(const FontDescription::FamilyDescription&); 57 void setFamilyDescription(const FontDescription::FamilyDescription&);
63 void setFeatureSettings(PassRefPtr<FontFeatureSettings>); 58 void setFeatureSettings(PassRefPtr<FontFeatureSettings>);
64 void setScript(const String& locale); 59 void setScript(const String& locale);
65 void setStyle(FontStyle); 60 void setStyle(FontStyle);
66 void setVariant(FontVariant); 61 void setVariant(FontVariant);
67 void setVariantLigatures(const FontDescription::VariantLigatures&); 62 void setVariantLigatures(const FontDescription::VariantLigatures&);
68 void setTextRendering(TextRenderingMode); 63 void setTextRendering(TextRenderingMode);
69 void setKerning(FontDescription::Kerning); 64 void setKerning(FontDescription::Kerning);
70 void setFontSmoothing(FontSmoothingMode); 65 void setFontSmoothing(FontSmoothingMode);
71 66
72 // FIXME: These need to just vend a Font object eventually. 67 // FIXME: These need to just vend a Font object eventually.
73 void createFont(PassRefPtrWillBeRawPtr<FontSelector>, RenderStyle*, const Re nderStyle* parentStyle); 68 void createFont(PassRefPtrWillBeRawPtr<FontSelector>, RenderStyle*);
74 69
75 void createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector>, RenderStyle *); 70 void createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector>, RenderStyle *);
76 71
77 // FIXME: These should not be necessary eventually. 72 bool fontDirty() const { return m_flags; }
78 void setFontDirty(bool fontDirty) { m_fontDirty = fontDirty; }
79 // FIXME: This is only used by an ASSERT in StyleResolver. Remove?
80 bool fontDirty() const { return m_fontDirty; }
81 73
82 static FontDescription::FamilyDescription initialFamilyDescription() { retur n FontDescription::FamilyDescription(initialGenericFamily()); } 74 static FontDescription::FamilyDescription initialFamilyDescription() { retur n FontDescription::FamilyDescription(initialGenericFamily()); }
83 static FontFeatureSettings* initialFeatureSettings() { return nullptr; } 75 static FontFeatureSettings* initialFeatureSettings() { return nullptr; }
84 static FontDescription::GenericFamilyType initialGenericFamily() { return Fo ntDescription::StandardFamily; } 76 static FontDescription::GenericFamilyType initialGenericFamily() { return Fo ntDescription::StandardFamily; }
85 static FontDescription::Size initialSize() { return FontDescription::Size(Fo ntSize::initialKeywordSize(), 0.0f, false); } 77 static FontDescription::Size initialSize() { return FontDescription::Size(Fo ntSize::initialKeywordSize(), 0.0f, false); }
86 static TextRenderingMode initialTextRendering() { return AutoTextRendering; } 78 static TextRenderingMode initialTextRendering() { return AutoTextRendering; }
87 static FontVariant initialVariant() { return FontVariantNormal; } 79 static FontVariant initialVariant() { return FontVariantNormal; }
88 static FontDescription::VariantLigatures initialVariantLigatures() { return FontDescription::VariantLigatures(); } 80 static FontDescription::VariantLigatures initialVariantLigatures() { return FontDescription::VariantLigatures(); }
89 static FontStyle initialStyle() { return FontStyleNormal; } 81 static FontStyle initialStyle() { return FontStyleNormal; }
90 static FontDescription::Kerning initialKerning() { return FontDescription::A utoKerning; } 82 static FontDescription::Kerning initialKerning() { return FontDescription::A utoKerning; }
91 static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; } 83 static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; }
92 static FontStretch initialStretch() { return FontStretchNormal; } 84 static FontStretch initialStretch() { return FontStretchNormal; }
93 static FontWeight initialWeight() { return FontWeightNormal; } 85 static FontWeight initialWeight() { return FontWeightNormal; }
94 86
95 friend class FontDescriptionChangeScope;
96
97 private: 87 private:
98 88
99 void setFamilyDescription(FontDescription&, const FontDescription::FamilyDes cription&); 89 void setFamilyDescription(FontDescription&, const FontDescription::FamilyDes cription&);
100 void setSize(FontDescription&, const FontDescription::Size&); 90 void setSize(FontDescription&, const FontDescription::Size&);
101 void checkForOrientationChange(RenderStyle*); 91 void updateOrientation(FontDescription&, RenderStyle*);
102 // This function fixes up the default font size if it detects that the curre nt generic font family has changed. -dwh 92 // This function fixes up the default font size if it detects that the curre nt generic font family has changed. -dwh
103 void checkForGenericFamilyChange(RenderStyle*, const RenderStyle* parentStyl e); 93 void checkForGenericFamilyChange(const FontDescription&, FontDescription&);
104 void updateComputedSize(RenderStyle*, const RenderStyle* parentStyle); 94 void updateSpecifiedSize(FontDescription&, RenderStyle*);
105 void updateComputedSize(FontDescription&, RenderStyle*); 95 void updateComputedSize(FontDescription&, RenderStyle*);
106 96
107 float getComputedSizeFromSpecifiedSize(FontDescription&, float effectiveZoom , float specifiedSize); 97 float getComputedSizeFromSpecifiedSize(FontDescription&, float effectiveZoom , float specifiedSize);
108 98
109 const Document& m_document; 99 const Document& m_document;
110 FontDescription m_fontDescription; 100 FontDescription m_fontDescription;
111 101
112 // Fontbuilder is responsbile for creating the Font() 102 enum class IsSetFlag {
rune 2015/02/03 12:25:40 How about something more descriptive like Descript
andersr 2015/02/03 15:35:08 Do you mean DescriptionFlag?
113 // object on RenderStyle from various other font-related 103 Weight,
114 // properties on RenderStyle. Whenever one of those 104 Size,
115 // is changed, FontBuilder tracks the need to update 105 Stretch,
116 // style->font() with this bool. 106 Family,
117 bool m_fontDirty; 107 FeatureSettings,
108 Script,
109 Style,
110 Variant,
111 VariantLigatures,
112 TextRendering,
113 Kerning,
114 FontSmoothing,
115
116 EffectiveZoom,
117 TextOrientation,
118 WritingMode
119 };
120
121 void set(IsSetFlag flag) { m_flags |= (1 << unsigned(flag)); }
122 bool isSet(IsSetFlag flag) const { return m_flags & (1 << unsigned(flag)); }
123
124 unsigned m_flags;
118 }; 125 };
119 126
120 } 127 }
121 128
122 #endif 129 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698