Text Autosizing: Add basic framework
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2012 19:57:22 +0000 (19:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2012 19:57:22 +0000 (19:57 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@121920 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/rendering/TextAutosizer.cpp
Source/WebCore/rendering/TextAutosizer.h

index 2d68195..d883e04 100644 (file)
@@ -1,3 +1,24 @@
+2012-07-05  John Mellor  <johnme@chromium.org>
+
+        Text Autosizing: Add basic framework
+        https://bugs.webkit.org/show_bug.cgi?id=88655
+
+        Follow-up patch tweaking method signatures.
+
+        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):
+
 2012-07-05  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: move cursor to the current search match.
index ca7b97a..e64ef90 100644 (file)
@@ -1116,8 +1116,8 @@ void FrameView::layout(bool allowSubtree)
             forceLayoutParentViewIfNeeded();
             root->layout();
 #if ENABLE(TEXT_AUTOSIZING)
-            bool boosted = document->textAutosizer()->boostSubtree(root);
-            if (boosted && root->needsLayout())
+            bool autosized = document->textAutosizer()->processSubtree(root);
+            if (autosized && root->needsLayout())
                 root->layout();
 #endif
             endDeferredRepaints();
index 127a21c..0824aa3 100644 (file)
@@ -42,7 +42,7 @@ TextAutosizer::~TextAutosizer()
 {
 }
 
-bool TextAutosizer::boostSubtree(RenderObject* layoutRoot)
+bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
 {
     // FIXME: Text Autosizing should only be enabled when m_document->page()->mainFrame()->view()->useFixedLayout()
     // is true, but for now it's useful to ignore this so that it can be tested on desktop.
@@ -58,38 +58,38 @@ bool TextAutosizer::boostSubtree(RenderObject* layoutRoot)
 
     for (RenderObject* descendant = traverseNext(layoutRoot, layoutRoot); descendant; descendant = traverseNext(descendant, layoutRoot)) {
         if (!treatAsInline(descendant))
-            boostBlock(toRenderBlock(descendant), windowSize);
+            processBlock(toRenderBlock(descendant), windowSize);
     }
 
     return true;
 }
 
-void TextAutosizer::boostBlock(RenderBlock* block, LayoutSize windowSize)
+void TextAutosizer::processBlock(RenderBlock* block, const IntSize& windowSize)
 {
-    float windowLogicalWidth = block->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();
-    float multiplier = block->logicalWidth() / windowLogicalWidth; // FIXME: This is overly simplistic.
+    int windowLogicalWidth = block->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();
+    float multiplier = static_cast<float>(block->logicalWidth()) / windowLogicalWidth; // FIXME: This is overly simplistic.
     if (multiplier < 1)
         return;
     for (RenderObject* descendant = traverseNext(block, block, treatAsInline); descendant; descendant = traverseNext(descendant, block, treatAsInline)) {
         if (descendant->isText())
-            boostText(toRenderText(descendant), multiplier);
+            processText(toRenderText(descendant), multiplier);
     }
 }
 
-void TextAutosizer::boostText(RenderText* text, float multiplier)
+void TextAutosizer::processText(RenderText* text, float multiplier)
 {
     float specifiedSize = text->style()->fontDescription().specifiedSize();
-    float boostedSize = specifiedSize * multiplier; // FIXME: This is overly simplistic.
+    float newSize = specifiedSize * multiplier; // FIXME: This is overly simplistic.
 
     RefPtr<RenderStyle> style = RenderStyle::clone(text->style());
     FontDescription fontDescription(style->fontDescription());
-    fontDescription.setComputedSize(boostedSize);
+    fontDescription.setComputedSize(newSize);
     style->setFontDescription(fontDescription);
     style->font().update(style->font().fontSelector());
     text->setStyle(style.release());
 
     // FIXME: Increase computed line height proportionately.
-    // FIXME: Boost list markers proportionately.
+    // FIXME: Increase list marker size proportionately.
 }
 
 bool TextAutosizer::treatAsInline(const RenderObject* renderer)
@@ -97,6 +97,7 @@ bool TextAutosizer::treatAsInline(const RenderObject* renderer)
     return !renderer->isRenderBlock() || renderer->isListItem() || renderer->isInlineBlockOrInlineTable();
 }
 
+// FIXME: Consider making this a method on RenderObject if it remains this generic.
 RenderObject* TextAutosizer::traverseNext(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilter filter)
 {
     for (RenderObject* child = current->firstChild(); child; child = child->nextSibling()) {
index cff42f9..f5e14cf 100644 (file)
@@ -49,13 +49,13 @@ public:
 
     virtual ~TextAutosizer();
 
-    bool boostSubtree(RenderObject* layoutRoot);
+    bool processSubtree(RenderObject* layoutRoot);
 
 private:
     explicit TextAutosizer(Document*);
 
-    void boostBlock(RenderBlock*, LayoutSize windowSize);
-    void boostText(RenderText*, float multiplier);
+    void processBlock(RenderBlock*, const IntSize& windowSize);
+    void processText(RenderText*, float multiplier);
 
     typedef bool (*RenderObjectFilter)(const RenderObject*);
     static bool treatAsInline(const RenderObject*);