| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef TextAutosizer_h | 26 #ifndef TextAutosizer_h |
| 27 #define TextAutosizer_h | 27 #define TextAutosizer_h |
| 28 | 28 |
| 29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "platform/heap/Handle.h" |
| 30 #include "platform/text/WritingMode.h" | 31 #include "platform/text/WritingMode.h" |
| 31 #include "wtf/HashMap.h" | 32 #include "wtf/HashMap.h" |
| 32 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
| 33 #include "wtf/OwnPtr.h" | 34 #include "wtf/OwnPtr.h" |
| 34 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 class Document; | 39 class Document; |
| 39 class RenderBlock; | 40 class RenderBlock; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 // Upper limit on the difference between the width of the cluster's block co
ntaining all | 56 // Upper limit on the difference between the width of the cluster's block co
ntaining all |
| 56 // text and that of a narrow child before the child becomes a separate clust
er. | 57 // text and that of a narrow child before the child becomes a separate clust
er. |
| 57 float maxAllowedDifferenceFromTextWidth; | 58 float maxAllowedDifferenceFromTextWidth; |
| 58 | 59 |
| 59 // Descendants of the cluster that are narrower than the block containing al
l text and must be | 60 // Descendants of the cluster that are narrower than the block containing al
l text and must be |
| 60 // processed together. | 61 // processed together. |
| 61 Vector<TextAutosizingClusterInfo> narrowDescendants; | 62 Vector<TextAutosizingClusterInfo> narrowDescendants; |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 class TextAutosizer FINAL { | 65 class TextAutosizer FINAL : public NoBaseWillBeGarbageCollectedFinalized<TextAut
osizer> { |
| 65 WTF_MAKE_NONCOPYABLE(TextAutosizer); | 66 WTF_MAKE_NONCOPYABLE(TextAutosizer); |
| 66 | |
| 67 public: | 67 public: |
| 68 static PassOwnPtr<TextAutosizer> create(Document* document) { return adoptPt
r(new TextAutosizer(document)); } | 68 static PassOwnPtrWillBeRawPtr<TextAutosizer> create(Document* document) |
| 69 { |
| 70 return adoptPtrWillBeNoop(new TextAutosizer(document)); |
| 71 } |
| 69 | 72 |
| 70 bool processSubtree(RenderObject* layoutRoot); | 73 bool processSubtree(RenderObject* layoutRoot); |
| 71 void recalculateMultipliers(); | 74 void recalculateMultipliers(); |
| 72 | 75 |
| 76 void trace(Visitor*); |
| 77 |
| 73 private: | 78 private: |
| 74 friend class FastTextAutosizer; | 79 friend class FastTextAutosizer; |
| 75 | 80 |
| 76 enum TraversalDirection { | 81 enum TraversalDirection { |
| 77 FirstToLast, | 82 FirstToLast, |
| 78 LastToFirst | 83 LastToFirst |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 explicit TextAutosizer(Document*); | 86 explicit TextAutosizer(Document*); |
| 82 | 87 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 124 |
| 120 // Returns groups of narrow descendants of a given autosizing cluster. The g
roups are combined | 125 // Returns groups of narrow descendants of a given autosizing cluster. The g
roups are combined |
| 121 // by the difference between the width of the descendant and the width of th
e parent cluster's | 126 // by the difference between the width of the descendant and the width of th
e parent cluster's |
| 122 // |blockContainingAllText|. | 127 // |blockContainingAllText|. |
| 123 static void getNarrowDescendantsGroupedByWidth(const TextAutosizingClusterIn
fo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >&); | 128 static void getNarrowDescendantsGroupedByWidth(const TextAutosizingClusterIn
fo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >&); |
| 124 | 129 |
| 125 void addNonAutosizedCluster(unsigned key, TextAutosizingClusterInfo& value); | 130 void addNonAutosizedCluster(unsigned key, TextAutosizingClusterInfo& value); |
| 126 void secondPassProcessStaleNonAutosizedClusters(); | 131 void secondPassProcessStaleNonAutosizedClusters(); |
| 127 void processStaleContainer(float multiplier, RenderBlock* cluster, TextAutos
izingClusterInfo&); | 132 void processStaleContainer(float multiplier, RenderBlock* cluster, TextAutos
izingClusterInfo&); |
| 128 | 133 |
| 129 Document* m_document; | 134 RawPtrWillBeMember<Document> m_document; |
| 130 | 135 |
| 131 HashMap<const RenderObject*, unsigned> m_hashCache; | 136 HashMap<const RenderObject*, unsigned> m_hashCache; |
| 132 | 137 |
| 133 // Mapping from all autosized (i.e. multiplier > 1) cluster hashes to their
respective multipliers. | 138 // Mapping from all autosized (i.e. multiplier > 1) cluster hashes to their
respective multipliers. |
| 134 HashMap<unsigned, float> m_hashToMultiplier; | 139 HashMap<unsigned, float> m_hashToMultiplier; |
| 135 Vector<unsigned> m_hashesToAutosizeSecondPass; | 140 Vector<unsigned> m_hashesToAutosizeSecondPass; |
| 136 | 141 |
| 137 // Mapping from a cluster hash to the corresponding cluster infos which have
not been autosized yet. | 142 // Mapping from a cluster hash to the corresponding cluster infos which have
not been autosized yet. |
| 138 HashMap<unsigned, OwnPtr<Vector<TextAutosizingClusterInfo> > > m_nonAutosize
dClusters; | 143 HashMap<unsigned, OwnPtr<Vector<TextAutosizingClusterInfo> > > m_nonAutosize
dClusters; |
| 139 | 144 |
| 140 bool m_previouslyAutosized; | 145 bool m_previouslyAutosized; |
| 141 }; | 146 }; |
| 142 | 147 |
| 143 } // namespace blink | 148 } // namespace blink |
| 144 | 149 |
| 145 #endif // TextAutosizer_h | 150 #endif // TextAutosizer_h |
| OLD | NEW |