Changeset 121920 in webkit


Ignore:
Timestamp:
Jul 5, 2012 12:57:22 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Text Autosizing: Add basic framework
https://bugs.webkit.org/show_bug.cgi?id=88655

Follow-up patch tweaking method signatures.

Patch by John Mellor <johnme@chromium.org> on 2012-07-05
Reviewed by Simon Fraser.

No functional change, so no new tests.

  • page/FrameView.cpp:

(WebCore::FrameView::layout):

  • rendering/TextAutosizer.cpp:

(WebCore::TextAutosizer::processSubtree):
(WebCore::TextAutosizer::processBlock):
(WebCore::TextAutosizer::processText):
(WebCore):

  • rendering/TextAutosizer.h:

(TextAutosizer):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121918 r121920  
     12012-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
    1222012-07-05  Pavel Feldman  <pfeldman@chromium.org>
    223
  • trunk/Source/WebCore/page/FrameView.cpp

    r121866 r121920  
    11171117            root->layout();
    11181118#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())
    11211121                root->layout();
    11221122#endif
  • trunk/Source/WebCore/rendering/TextAutosizer.cpp

    r121907 r121920  
    4343}
    4444
    45 bool TextAutosizer::boostSubtree(RenderObject* layoutRoot)
     45bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
    4646{
    4747    // FIXME: Text Autosizing should only be enabled when m_document->page()->mainFrame()->view()->useFixedLayout()
     
    5959    for (RenderObject* descendant = traverseNext(layoutRoot, layoutRoot); descendant; descendant = traverseNext(descendant, layoutRoot)) {
    6060        if (!treatAsInline(descendant))
    61             boostBlock(toRenderBlock(descendant), windowSize);
     61            processBlock(toRenderBlock(descendant), windowSize);
    6262    }
    6363
     
    6565}
    6666
    67 void TextAutosizer::boostBlock(RenderBlock* block, LayoutSize windowSize)
     67void TextAutosizer::processBlock(RenderBlock* block, const IntSize& windowSize)
    6868{
    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.
    7171    if (multiplier < 1)
    7272        return;
    7373    for (RenderObject* descendant = traverseNext(block, block, treatAsInline); descendant; descendant = traverseNext(descendant, block, treatAsInline)) {
    7474        if (descendant->isText())
    75             boostText(toRenderText(descendant), multiplier);
     75            processText(toRenderText(descendant), multiplier);
    7676    }
    7777}
    7878
    79 void TextAutosizer::boostText(RenderText* text, float multiplier)
     79void TextAutosizer::processText(RenderText* text, float multiplier)
    8080{
    8181    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.
    8383
    8484    RefPtr<RenderStyle> style = RenderStyle::clone(text->style());
    8585    FontDescription fontDescription(style->fontDescription());
    86     fontDescription.setComputedSize(boostedSize);
     86    fontDescription.setComputedSize(newSize);
    8787    style->setFontDescription(fontDescription);
    8888    style->font().update(style->font().fontSelector());
     
    9090
    9191    // FIXME: Increase computed line height proportionately.
    92     // FIXME: Boost list markers proportionately.
     92    // FIXME: Increase list marker size proportionately.
    9393}
    9494
     
    9898}
    9999
     100// FIXME: Consider making this a method on RenderObject if it remains this generic.
    100101RenderObject* TextAutosizer::traverseNext(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilter filter)
    101102{
  • trunk/Source/WebCore/rendering/TextAutosizer.h

    r121866 r121920  
    5050    virtual ~TextAutosizer();
    5151
    52     bool boostSubtree(RenderObject* layoutRoot);
     52    bool processSubtree(RenderObject* layoutRoot);
    5353
    5454private:
    5555    explicit TextAutosizer(Document*);
    5656
    57     void boostBlock(RenderBlock*, LayoutSize windowSize);
    58     void boostText(RenderText*, float multiplier);
     57    void processBlock(RenderBlock*, const IntSize& windowSize);
     58    void processText(RenderText*, float multiplier);
    5959
    6060    typedef bool (*RenderObjectFilter)(const RenderObject*);
Note: See TracChangeset for help on using the changeset viewer.