Changeset 121920 in webkit
- Timestamp:
- Jul 5, 2012 12:57:22 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121918 r121920 1 2012-07-05 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Add basic framework 4 https://bugs.webkit.org/show_bug.cgi?id=88655 5 6 Follow-up patch tweaking method signatures. 7 8 Reviewed by Simon Fraser. 9 10 No functional change, so no new tests. 11 12 * page/FrameView.cpp: 13 (WebCore::FrameView::layout): 14 * rendering/TextAutosizer.cpp: 15 (WebCore::TextAutosizer::processSubtree): 16 (WebCore::TextAutosizer::processBlock): 17 (WebCore::TextAutosizer::processText): 18 (WebCore): 19 * rendering/TextAutosizer.h: 20 (TextAutosizer): 21 1 22 2012-07-05 Pavel Feldman <pfeldman@chromium.org> 2 23 -
trunk/Source/WebCore/page/FrameView.cpp
r121866 r121920 1117 1117 root->layout(); 1118 1118 #if ENABLE(TEXT_AUTOSIZING) 1119 bool boosted = document->textAutosizer()->boostSubtree(root);1120 if ( boosted && root->needsLayout())1119 bool autosized = document->textAutosizer()->processSubtree(root); 1120 if (autosized && root->needsLayout()) 1121 1121 root->layout(); 1122 1122 #endif -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r121907 r121920 43 43 } 44 44 45 bool TextAutosizer:: boostSubtree(RenderObject* layoutRoot)45 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) 46 46 { 47 47 // FIXME: Text Autosizing should only be enabled when m_document->page()->mainFrame()->view()->useFixedLayout() … … 59 59 for (RenderObject* descendant = traverseNext(layoutRoot, layoutRoot); descendant; descendant = traverseNext(descendant, layoutRoot)) { 60 60 if (!treatAsInline(descendant)) 61 boostBlock(toRenderBlock(descendant), windowSize);61 processBlock(toRenderBlock(descendant), windowSize); 62 62 } 63 63 … … 65 65 } 66 66 67 void TextAutosizer:: boostBlock(RenderBlock* block, LayoutSizewindowSize)67 void TextAutosizer::processBlock(RenderBlock* block, const IntSize& windowSize) 68 68 { 69 float windowLogicalWidth = block->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();70 float multiplier = block->logicalWidth() / windowLogicalWidth; // FIXME: This is overly simplistic.69 int windowLogicalWidth = block->isHorizontalWritingMode() ? windowSize.width() : windowSize.height(); 70 float multiplier = static_cast<float>(block->logicalWidth()) / windowLogicalWidth; // FIXME: This is overly simplistic. 71 71 if (multiplier < 1) 72 72 return; 73 73 for (RenderObject* descendant = traverseNext(block, block, treatAsInline); descendant; descendant = traverseNext(descendant, block, treatAsInline)) { 74 74 if (descendant->isText()) 75 boostText(toRenderText(descendant), multiplier);75 processText(toRenderText(descendant), multiplier); 76 76 } 77 77 } 78 78 79 void TextAutosizer:: boostText(RenderText* text, float multiplier)79 void TextAutosizer::processText(RenderText* text, float multiplier) 80 80 { 81 81 float specifiedSize = text->style()->fontDescription().specifiedSize(); 82 float boostedSize = specifiedSize * multiplier; // FIXME: This is overly simplistic.82 float newSize = specifiedSize * multiplier; // FIXME: This is overly simplistic. 83 83 84 84 RefPtr<RenderStyle> style = RenderStyle::clone(text->style()); 85 85 FontDescription fontDescription(style->fontDescription()); 86 fontDescription.setComputedSize( boostedSize);86 fontDescription.setComputedSize(newSize); 87 87 style->setFontDescription(fontDescription); 88 88 style->font().update(style->font().fontSelector()); … … 90 90 91 91 // FIXME: Increase computed line height proportionately. 92 // FIXME: Boost list markersproportionately.92 // FIXME: Increase list marker size proportionately. 93 93 } 94 94 … … 98 98 } 99 99 100 // FIXME: Consider making this a method on RenderObject if it remains this generic. 100 101 RenderObject* TextAutosizer::traverseNext(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilter filter) 101 102 { -
trunk/Source/WebCore/rendering/TextAutosizer.h
r121866 r121920 50 50 virtual ~TextAutosizer(); 51 51 52 bool boostSubtree(RenderObject* layoutRoot);52 bool processSubtree(RenderObject* layoutRoot); 53 53 54 54 private: 55 55 explicit TextAutosizer(Document*); 56 56 57 void boostBlock(RenderBlock*, LayoutSizewindowSize);58 void boostText(RenderText*, float multiplier);57 void processBlock(RenderBlock*, const IntSize& windowSize); 58 void processText(RenderText*, float multiplier); 59 59 60 60 typedef bool (*RenderObjectFilter)(const RenderObject*);
Note: See TracChangeset
for help on using the changeset viewer.