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 27 matching lines...) Expand all Loading... | |
38 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
39 #include "core/rendering/InlineIterator.h" | 39 #include "core/rendering/InlineIterator.h" |
40 #include "core/rendering/RenderBlock.h" | 40 #include "core/rendering/RenderBlock.h" |
41 #include "core/rendering/RenderView.h" | 41 #include "core/rendering/RenderView.h" |
42 #include "core/rendering/TextAutosizer.h" | 42 #include "core/rendering/TextAutosizer.h" |
43 | 43 |
44 using namespace std; | 44 using namespace std; |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 using namespace HTMLNames; | |
49 | |
48 FastTextAutosizer::FastTextAutosizer(const Document* document) | 50 FastTextAutosizer::FastTextAutosizer(const Document* document) |
49 : m_document(document) | 51 : m_document(document) |
50 #ifndef NDEBUG | 52 #ifndef NDEBUG |
51 , m_renderViewInfoPrepared(false) | 53 , m_renderViewInfoPrepared(false) |
52 #endif | 54 #endif |
53 { | 55 { |
54 } | 56 } |
55 | 57 |
56 void FastTextAutosizer::record(const RenderBlock* block) | 58 void FastTextAutosizer::record(const RenderBlock* block) |
57 { | 59 { |
(...skipping 27 matching lines...) Expand all Loading... | |
85 return; | 87 return; |
86 #ifndef NDEBUG | 88 #ifndef NDEBUG |
87 m_blocksThatHaveBegunLayout.add(block); | 89 m_blocksThatHaveBegunLayout.add(block); |
88 #endif | 90 #endif |
89 | 91 |
90 if (block->isRenderView()) | 92 if (block->isRenderView()) |
91 prepareRenderViewInfo(toRenderView(block)); | 93 prepareRenderViewInfo(toRenderView(block)); |
92 | 94 |
93 if (Cluster* cluster = maybeGetOrCreateCluster(block)) | 95 if (Cluster* cluster = maybeGetOrCreateCluster(block)) |
94 m_clusterStack.append(cluster); | 96 m_clusterStack.append(cluster); |
95 | 97 |
pdr.
2014/01/25 03:50:23
Do we need to skip inflation here for list items w
skobes
2014/01/28 03:10:30
No, inflateListItem only sets the multiplier on th
| |
96 if (block->childrenInline()) | 98 if (block->childrenInline()) |
97 inflate(block); | 99 inflate(block); |
98 } | 100 } |
99 | 101 |
102 void FastTextAutosizer::inflateListItem(RenderBlock* listItem, RenderObject* lis tItemMarker) | |
103 { | |
104 #ifndef NDEBUG | |
pdr.
2014/01/25 03:50:23
These ifndef's aren't needed because the asserts w
skobes
2014/01/28 03:10:30
Done.
| |
105 ASSERT(listItem->isListItem()); | |
106 ASSERT(listItemMarker->isListMarker()); | |
107 #endif | |
108 if (!enabled()) | |
109 return; | |
110 | |
111 applyMultiplier(listItem, activeMultiplier()); | |
pdr.
2014/01/25 03:50:23
I'm not sure we can call activeMultiplier() here.
skobes
2014/01/28 03:10:30
Fixed.
| |
112 applyMultiplier(listItemMarker, activeMultiplier()); | |
113 } | |
114 | |
100 void FastTextAutosizer::endLayout(RenderBlock* block) | 115 void FastTextAutosizer::endLayout(RenderBlock* block) |
101 { | 116 { |
102 if (!enabled()) | 117 if (!enabled()) |
103 return; | 118 return; |
104 #ifndef NDEBUG | 119 #ifndef NDEBUG |
105 m_blocksThatHaveBegunLayout.remove(block); | 120 m_blocksThatHaveBegunLayout.remove(block); |
106 #endif | 121 #endif |
107 | 122 |
108 Cluster* cluster = currentCluster(); | 123 Cluster* cluster = currentCluster(); |
109 if (cluster && cluster->m_root == block) | 124 if (cluster && cluster->m_root == block) |
110 m_clusterStack.removeLast(); | 125 m_clusterStack.removeLast(); |
111 } | 126 } |
112 | 127 |
128 float FastTextAutosizer::activeMultiplier() | |
129 { | |
130 Cluster* cluster = currentCluster(); | |
131 if (!cluster) | |
132 return 1.0f; | |
133 return cluster->m_autosize ? cluster->m_multiplier : 1.0f; | |
pdr.
2014/01/25 03:50:23
We should add an assert that the multiplier has be
skobes
2014/01/28 03:10:30
Done.
| |
134 } | |
135 | |
113 void FastTextAutosizer::inflate(RenderBlock* block) | 136 void FastTextAutosizer::inflate(RenderBlock* block) |
114 { | 137 { |
115 Cluster* cluster = currentCluster(); | 138 Cluster* cluster = currentCluster(); |
116 if (!cluster) | 139 if (!cluster) |
117 return; | 140 return; |
118 | 141 |
119 float multiplier = 0; | 142 float multiplier = 0; |
120 for (RenderObject* descendant = nextChildSkippingChildrenOfBlocks(block, blo ck); descendant; descendant = nextChildSkippingChildrenOfBlocks(descendant, bloc k)) { | 143 for (RenderObject* descendant = nextChildSkippingChildrenOfBlocks(block, blo ck); descendant; descendant = nextChildSkippingChildrenOfBlocks(descendant, bloc k)) { |
121 if (descendant->isText()) { | 144 if (descendant->isText()) { |
122 // We only calculate this multiplier on-demand to ensure the parent block of this text | 145 // We only calculate this multiplier on-demand to ensure the parent block of this text |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 } | 444 } |
422 | 445 |
423 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO bject* current, const RenderObject* stayWithin) | 446 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO bject* current, const RenderObject* stayWithin) |
424 { | 447 { |
425 if (current == stayWithin || !current->isRenderBlock()) | 448 if (current == stayWithin || !current->isRenderBlock()) |
426 return current->nextInPreOrder(stayWithin); | 449 return current->nextInPreOrder(stayWithin); |
427 return current->nextInPreOrderAfterChildren(stayWithin); | 450 return current->nextInPreOrderAfterChildren(stayWithin); |
428 } | 451 } |
429 | 452 |
430 } // namespace WebCore | 453 } // namespace WebCore |
OLD | NEW |