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

Side by Side Diff: Source/WebCore/rendering/TextAutosizer.h

Issue 11859014: Merge 138111 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 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/WebCore/ChangeLog ('k') | Source/WebCore/rendering/TextAutosizer.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) 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
(...skipping 10 matching lines...) Expand all
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 #if ENABLE(TEXT_AUTOSIZING) 29 #if ENABLE(TEXT_AUTOSIZING)
30 30
31 #include "IntSize.h"
32 #include <wtf/Noncopyable.h> 31 #include <wtf/Noncopyable.h>
33 #include <wtf/PassOwnPtr.h> 32 #include <wtf/PassOwnPtr.h>
34 #include <wtf/PassRefPtr.h>
35 33
36 namespace WebCore { 34 namespace WebCore {
37 35
38 class Document; 36 class Document;
39 class RenderBlock; 37 class RenderBlock;
40 class RenderObject; 38 class RenderObject;
41 class RenderStyle;
42 class RenderText; 39 class RenderText;
43 struct TextAutosizingWindowInfo; 40 struct TextAutosizingWindowInfo;
44 41
45 class TextAutosizer { 42 class TextAutosizer {
46 WTF_MAKE_NONCOPYABLE(TextAutosizer); 43 WTF_MAKE_NONCOPYABLE(TextAutosizer);
47 44
48 public: 45 public:
49 static PassOwnPtr<TextAutosizer> create(Document* document) { return adoptPt r(new TextAutosizer(document)); } 46 static PassOwnPtr<TextAutosizer> create(Document* document) { return adoptPt r(new TextAutosizer(document)); }
50 47
51 virtual ~TextAutosizer(); 48 virtual ~TextAutosizer();
52 49
53 bool processSubtree(RenderObject* layoutRoot); 50 bool processSubtree(RenderObject* layoutRoot);
54 51
55 static float computeAutosizedFontSize(float specifiedSize, float multiplier) ; 52 static float computeAutosizedFontSize(float specifiedSize, float multiplier) ;
56 53
57 private: 54 private:
58 enum TraversalDirection { 55 enum TraversalDirection {
59 FirstToLast, 56 FirstToLast,
60 LastToFirst 57 LastToFirst
61 }; 58 };
62 59
63 explicit TextAutosizer(Document*); 60 explicit TextAutosizer(Document*);
64 61
65 void processCluster(RenderBlock* cluster, RenderBlock* container, RenderObje ct* subtreeRoot, const TextAutosizingWindowInfo&); 62 void processCluster(RenderBlock* cluster, RenderBlock* container, RenderObje ct* subtreeRoot, const TextAutosizingWindowInfo&);
66 void processContainer(float multiplier, RenderBlock* container, RenderObject * subtreeRoot, const TextAutosizingWindowInfo&); 63 void processContainer(float multiplier, RenderBlock* container, const Render Block* blockContainingAllText, RenderObject* subtreeRoot, const TextAutosizingWi ndowInfo&);
67 64
68 void setMultiplier(RenderObject*, float); 65 void setMultiplier(RenderObject*, float);
69 66
70 static bool isAutosizingContainer(const RenderObject*); 67 static bool isAutosizingContainer(const RenderObject*);
71 static bool isAutosizingCluster(const RenderBlock*); 68 static bool isAutosizingCluster(const RenderBlock*, const RenderBlock* paren tBlockContainingAllText);
69 static bool isAutosizingCluster(const RenderObject*);
72 70
73 static bool containerShouldbeAutosized(const RenderBlock* container); 71 static bool containerShouldBeAutosized(const RenderBlock* container);
74 static bool clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor , float commonAncestorWidth); 72 static bool clusterShouldBeAutosized(const RenderBlock* blockContainingAllTe xt, float blockWidth);
75 static void measureDescendantTextWidth(const RenderBlock* container, float m inTextWidth, float& textWidth); 73 static void measureDescendantTextWidth(const RenderBlock* container, const R enderBlock* blockContainingAllText, float minTextWidth, float& textWidth);
76 74
77 // Use to traverse the tree of descendants, excluding descendants of contain ers (but returning the containers themselves). 75 // Use to traverse the tree of descendants, excluding descendants of contain ers (but returning the containers themselves).
78 static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const Ren derObject* current, const RenderObject* stayWithin); 76 static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const Ren derObject*, const RenderObject* stayWithin);
79 77
80 // Finds the lowest common ancestor of the first and the last descendant
81 // text node (excluding those belonging to other autosizing clusters).
82 static const RenderBlock* findDeepestBlockContainingAllText(const RenderBloc k* cluster); 78 static const RenderBlock* findDeepestBlockContainingAllText(const RenderBloc k* cluster);
83 79
84 // Depending on the traversal direction specified, finds the first or the la st leaf text node child that doesn't 80 // Depending on the traversal direction specified, finds the first or the la st leaf text node child that doesn't
85 // belong to any cluster. 81 // belong to any cluster.
86 static const RenderObject* findFirstTextLeafNotInCluster(const RenderObject* , size_t& depth, TraversalDirection); 82 static const RenderObject* findFirstTextLeafNotInCluster(const RenderObject* , size_t& depth, TraversalDirection);
87 83
88 Document* m_document; 84 Document* m_document;
89 }; 85 };
90 86
91 } // namespace WebCore 87 } // namespace WebCore
92 88
93 #endif // ENABLE(TEXT_AUTOSIZING) 89 #endif // ENABLE(TEXT_AUTOSIZING)
94 90
95 #endif // TextAutosizer_h 91 #endif // TextAutosizer_h
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | Source/WebCore/rendering/TextAutosizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698