OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 | 60 |
61 void record(RenderBlock*); | 61 void record(RenderBlock*); |
62 void destroy(RenderBlock*); | 62 void destroy(RenderBlock*); |
63 | 63 |
64 void beginLayout(RenderBlock*); | 64 void beginLayout(RenderBlock*); |
65 void inflate(RenderBlock*); | 65 void inflate(RenderBlock*); |
66 void endLayout(RenderBlock*); | 66 void endLayout(RenderBlock*); |
67 | 67 |
68 private: | 68 private: |
69 struct Cluster { | 69 struct Cluster { |
70 explicit Cluster(RenderBlock* root, float multiplier) | 70 explicit Cluster(RenderBlock* root, bool autosize, float multiplier) |
71 : m_root(root) | 71 : m_root(root) |
72 , m_autosize(autosize) | |
72 , m_multiplier(multiplier) | 73 , m_multiplier(multiplier) |
73 { | 74 { |
74 } | 75 } |
75 RenderBlock* m_root; | 76 RenderBlock* m_root; |
77 bool m_autosize; | |
pdr.
2014/01/14 02:50:03
Can you add a comment here (or above Cluster) that
| |
76 float m_multiplier; | 78 float m_multiplier; |
77 }; | 79 }; |
78 | 80 |
79 typedef WTF::HashSet<RenderBlock*> BlockSet; | 81 typedef WTF::HashSet<RenderBlock*> BlockSet; |
80 typedef WTF::HashMap<RenderBlock*, OwnPtr<Cluster> > ClusterMap; | 82 typedef WTF::HashMap<RenderBlock*, OwnPtr<Cluster> > ClusterMap; |
81 typedef WTF::Vector<Cluster*> ClusterStack; | 83 typedef WTF::Vector<Cluster*> ClusterStack; |
82 | 84 |
83 // Fingerprints are computed during style recalc, for (some subset of) | 85 // Fingerprints are computed during style recalc, for (some subset of) |
84 // blocks that will become cluster roots. | 86 // blocks that will become cluster roots. |
85 class FingerprintMapper { | 87 class FingerprintMapper { |
86 public: | 88 public: |
87 void add(RenderBlock*, AtomicString); | 89 void add(RenderBlock*, AtomicString); |
88 void remove(RenderBlock*); | 90 void remove(RenderBlock*); |
89 AtomicString get(RenderBlock*); | 91 AtomicString get(RenderBlock*); |
90 BlockSet& getBlocks(AtomicString); | 92 BlockSet& getBlocks(AtomicString); |
91 private: | 93 private: |
92 typedef WTF::HashMap<RenderBlock*, AtomicString> FingerprintMap; | 94 typedef WTF::HashMap<RenderBlock*, AtomicString> FingerprintMap; |
93 typedef WTF::HashMap<AtomicString, OwnPtr<BlockSet> > ReverseFingerprint Map; | 95 typedef WTF::HashMap<AtomicString, OwnPtr<BlockSet> > ReverseFingerprint Map; |
94 | 96 |
95 FingerprintMap m_fingerprints; | 97 FingerprintMap m_fingerprints; |
96 ReverseFingerprintMap m_blocksForFingerprint; | 98 ReverseFingerprintMap m_blocksForFingerprint; |
97 }; | 99 }; |
98 | 100 |
99 explicit FastTextAutosizer(Document*); | 101 explicit FastTextAutosizer(Document*); |
100 | 102 |
101 bool enabled(); | 103 bool enabled(); |
102 void prepareRenderViewInfo(RenderView*); | 104 void prepareRenderViewInfo(RenderView*); |
103 bool shouldBeClusterRoot(RenderBlock*); | 105 bool isFingerprintingCandidate(RenderBlock*); |
104 bool clusterWantsAutosizing(RenderBlock*); | 106 bool clusterWantsAutosizing(RenderBlock*); |
105 AtomicString computeFingerprint(RenderBlock*); | 107 AtomicString computeFingerprint(RenderBlock*); |
106 Cluster* getOrCreateCluster(RenderBlock*); | 108 Cluster* maybeGetOrCreateCluster(RenderBlock*); |
107 Cluster* createCluster(RenderBlock*); | |
108 Cluster* addSupercluster(AtomicString, RenderBlock*); | 109 Cluster* addSupercluster(AtomicString, RenderBlock*); |
109 RenderBlock* deepestCommonAncestor(BlockSet&); | 110 RenderBlock* deepestCommonAncestor(BlockSet&); |
110 float computeMultiplier(RenderBlock*); | 111 float computeMultiplier(RenderBlock*); |
111 void applyMultiplier(RenderObject*, float); | 112 void applyMultiplier(RenderObject*, float); |
112 | 113 |
113 Document* m_document; | 114 Document* m_document; |
114 int m_windowWidth; // Frame width in density-independent pixels (DIPs). | 115 int m_windowWidth; // Frame width in density-independent pixels (DIPs). |
115 int m_layoutWidth; // Layout width in CSS pixels. | 116 int m_layoutWidth; // Layout width in CSS pixels. |
116 float m_baseMultiplier; // Includes accessibility font scale factor and devi ce scale adjustment. | 117 float m_baseMultiplier; // Includes accessibility font scale factor and devi ce scale adjustment. |
117 #ifndef NDEBUG | 118 #ifndef NDEBUG |
118 bool m_renderViewInfoPrepared; // Used for assertions. | 119 bool m_renderViewInfoPrepared; // Used for assertions. |
119 #endif | 120 #endif |
120 | 121 |
121 // Clusters are created and destroyed during layout. The map key is the | 122 // Clusters are created and destroyed during layout. The map key is the |
122 // cluster root. Clusters whose roots share the same fingerprint use the | 123 // cluster root. Clusters whose roots share the same fingerprint use the |
123 // same multiplier. | 124 // same multiplier. |
124 ClusterMap m_clusters; | 125 ClusterMap m_clusters; |
125 ClusterStack m_clusterStack; | 126 ClusterStack m_clusterStack; |
126 FingerprintMapper m_fingerprintMapper; | 127 FingerprintMapper m_fingerprintMapper; |
127 }; | 128 }; |
128 | 129 |
129 } // namespace WebCore | 130 } // namespace WebCore |
130 | 131 |
131 #endif // FastTextAutosizer_h | 132 #endif // FastTextAutosizer_h |
OLD | NEW |