| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 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 endLayout(RenderBlock*); | 65 void endLayout(RenderBlock*); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 struct Cluster { | 68 struct Cluster { |
| 69 explicit Cluster(RenderBlock* root, float multiplier) | 69 explicit Cluster(RenderBlock* root, bool autosize, float multiplier) |
| 70 : m_root(root) | 70 : m_root(root) |
| 71 , m_autosize(autosize) |
| 71 , m_multiplier(multiplier) | 72 , m_multiplier(multiplier) |
| 72 { | 73 { |
| 73 } | 74 } |
| 74 RenderBlock* m_root; | 75 RenderBlock* m_root; |
| 76 bool m_autosize; |
| 75 float m_multiplier; | 77 float m_multiplier; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 typedef WTF::HashSet<RenderBlock*> BlockSet; | 80 typedef WTF::HashSet<RenderBlock*> BlockSet; |
| 79 typedef WTF::HashMap<RenderBlock*, OwnPtr<Cluster> > ClusterMap; | 81 typedef WTF::HashMap<RenderBlock*, OwnPtr<Cluster> > ClusterMap; |
| 80 typedef WTF::Vector<Cluster*> ClusterStack; | 82 typedef WTF::Vector<Cluster*> ClusterStack; |
| 81 | 83 |
| 82 // Fingerprints are computed during style recalc, for (some subset of) | 84 // Fingerprints are computed during style recalc, for (some subset of) |
| 83 // blocks that will become cluster roots. | 85 // blocks that will become cluster roots. |
| 84 class FingerprintMapper { | 86 class FingerprintMapper { |
| 85 public: | 87 public: |
| 86 void add(RenderBlock*, AtomicString); | 88 void add(RenderBlock*, AtomicString); |
| 87 void remove(RenderBlock*); | 89 void remove(RenderBlock*); |
| 88 AtomicString get(RenderBlock*); | 90 AtomicString get(RenderBlock*); |
| 89 BlockSet& getBlocks(AtomicString); | 91 BlockSet& getBlocks(AtomicString); |
| 90 private: | 92 private: |
| 91 typedef WTF::HashMap<RenderBlock*, AtomicString> FingerprintMap; | 93 typedef WTF::HashMap<RenderBlock*, AtomicString> FingerprintMap; |
| 92 typedef WTF::HashMap<AtomicString, OwnPtr<BlockSet> > ReverseFingerprint
Map; | 94 typedef WTF::HashMap<AtomicString, OwnPtr<BlockSet> > ReverseFingerprint
Map; |
| 93 | 95 |
| 94 FingerprintMap m_fingerprints; | 96 FingerprintMap m_fingerprints; |
| 95 ReverseFingerprintMap m_blocksForFingerprint; | 97 ReverseFingerprintMap m_blocksForFingerprint; |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 explicit FastTextAutosizer(Document*); | 100 explicit FastTextAutosizer(Document*); |
| 99 | 101 |
| 100 void inflate(RenderBlock*); | 102 void inflate(RenderBlock*); |
| 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 |