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

Side by Side Diff: Source/core/rendering/FastTextAutosizer.h

Issue 101543009: Make cluster creation independent of fingerprinting. Keep track of current (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pdr-multiplier
Patch Set: Created 6 years, 11 months 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
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/rendering/FastTextAutosizer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 class FastTextAutosizer FINAL { 52 class FastTextAutosizer FINAL {
53 WTF_MAKE_NONCOPYABLE(FastTextAutosizer); 53 WTF_MAKE_NONCOPYABLE(FastTextAutosizer);
54 54
55 public: 55 public:
56 static PassOwnPtr<FastTextAutosizer> create(Document* document) 56 static PassOwnPtr<FastTextAutosizer> create(Document* document)
57 { 57 {
58 return adoptPtr(new FastTextAutosizer(document)); 58 return adoptPtr(new FastTextAutosizer(document));
59 } 59 }
60 60
61 void prepareForLayout();
62
63 void record(RenderBlock*); 61 void record(RenderBlock*);
64 void destroy(RenderBlock*); 62 void destroy(RenderBlock*);
63
64 void beginLayout(RenderBlock*);
65 void inflate(RenderBlock*); 65 void inflate(RenderBlock*);
66 void endLayout(RenderBlock*);
66 67
67 private: 68 private:
68 // FIXME(crbug.com/327811): make a proper API for this class.
69 struct Cluster { 69 struct Cluster {
70 explicit Cluster(AtomicString fingerprint) 70 explicit Cluster(RenderBlock* root, float multiplier)
71 : m_fingerprint(fingerprint) 71 : m_root(root)
72 , m_multiplier(0) 72 , m_multiplier(multiplier)
73 { 73 {
74 } 74 }
75 RenderBlock* m_root;
76 float m_multiplier;
77 };
75 78
76 AtomicString m_fingerprint; 79 typedef WTF::HashSet<RenderBlock*> BlockSet;
77 WTF::HashSet<RenderBlock*> m_blocks; 80 typedef WTF::HashMap<RenderBlock*, OwnPtr<Cluster> > ClusterMap;
78 float m_multiplier; 81 typedef WTF::Vector<Cluster*> ClusterStack;
79 const RenderObject* m_clusterRoot;
80 82
81 void addBlock(RenderBlock* block) 83 // Fingerprints are computed during style recalc, for (some subset of)
82 { 84 // blocks that will become cluster roots.
83 m_blocks.add(block); 85 class FingerprintMapper {
84 setNeedsClusterRecalc(); 86 public:
85 } 87 void add(RenderBlock*, AtomicString);
88 void remove(RenderBlock*);
89 AtomicString get(RenderBlock*);
90 BlockSet& getBlocks(AtomicString);
91 private:
92 typedef WTF::HashMap<RenderBlock*, AtomicString> FingerprintMap;
93 typedef WTF::HashMap<AtomicString, OwnPtr<BlockSet> > ReverseFingerprint Map;
86 94
87 void setNeedsClusterRecalc() { m_multiplier = 0; m_clusterRoot = 0; } 95 FingerprintMap m_fingerprints;
88 bool needsClusterRecalc() const { return !m_clusterRoot || m_multiplier <= 0; } 96 ReverseFingerprintMap m_blocksForFingerprint;
89 }; 97 };
90 98
91 explicit FastTextAutosizer(Document*); 99 explicit FastTextAutosizer(Document*);
92 100
93 bool updateWindowWidth(); 101 bool enabled();
94 102 void prepareWindowInfo(RenderView*);
95 AtomicString fingerprint(const RenderBlock*); 103 bool shouldBeClusterRoot(RenderBlock*);
96 void recalcClusterIfNeeded(Cluster*); 104 bool clusterWantsAutosizing(RenderBlock*);
97 105 AtomicString computeFingerprint(RenderBlock*);
98 int m_windowWidth; 106 Cluster* getOrCreateCluster(RenderBlock*);
107 Cluster* createCluster(RenderBlock*);
108 Cluster* addSupercluster(AtomicString, RenderBlock*);
109 RenderBlock* deepestCommonAncestor(BlockSet&);
110 float computeMultiplier(RenderBlock*);
111 void applyMultiplier(RenderObject*, float);
99 112
100 Document* m_document; 113 Document* m_document;
114 int m_windowWidth; // Frame width in density-independent pixels (DIPs).
115 int m_layoutWidth; // Layout width in CSS pixels.
101 116
102 typedef WTF::HashMap<const RenderBlock*, Cluster*> BlockToClusterMap; 117 // Clusters are created and destroyed during layout. The map key is the
103 typedef WTF::HashMap<AtomicString, OwnPtr<Cluster> > FingerprintToClusterMap ; 118 // cluster root. Clusters whose roots share the same fingerprint use the
104 BlockToClusterMap m_clusterForBlock; 119 // same multiplier.
105 FingerprintToClusterMap m_clusterForFingerprint; 120 ClusterMap m_clusters;
121 ClusterStack m_clusterStack;
122 FingerprintMapper m_fingerprintMapper;
106 }; 123 };
107 124
108 } // namespace WebCore 125 } // namespace WebCore
109 126
110 #endif // FastTextAutosizer_h 127 #endif // FastTextAutosizer_h
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/rendering/FastTextAutosizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698