[Text Autosizing] Cleanup change: converter the pointer argument to be a reference...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Feb 2013 18:34:02 +0000 (18:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Feb 2013 18:34:02 +0000 (18:34 +0000)
non-null pointer is always expected.
https://bugs.webkit.org/show_bug.cgi?id=109079

Patch by Anton Vayvod <avayvod@chromium.org> on 2013-02-09
Reviewed by Kenneth Rohde Christiansen.

Cleanup change, no need to add new tests or modify the existing ones.

* rendering/TextAutosizer.cpp:

Changed parameter from a pointer to a reference in the methods below.

(WebCore::TextAutosizer::processSubtree):
(WebCore::TextAutosizer::processCluster):
(WebCore::TextAutosizer::processContainer):
(WebCore::TextAutosizer::isNarrowDescendant):
(WebCore::TextAutosizer::isWiderDescendant):
(WebCore::TextAutosizer::isAutosizingCluster):
(WebCore::TextAutosizer::clusterShouldBeAutosized):
(WebCore::TextAutosizer::measureDescendantTextWidth):

* rendering/TextAutosizer.h: updated method prototypes.

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

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

index a5aadc82cd9dceedac9703ade06fd3af8fb7159c..81b382e890f010f6c1fc57f879eff16bafa3fd31 100644 (file)
@@ -1,3 +1,28 @@
+2013-02-09  Anton Vayvod  <avayvod@chromium.org>
+        [Text Autosizing] Cleanup change: converter the pointer argument to be a reference since
+        non-null pointer is always expected.
+        https://bugs.webkit.org/show_bug.cgi?id=109079
+        Reviewed by Kenneth Rohde Christiansen.
+        Cleanup change, no need to add new tests or modify the existing ones.
+        * rendering/TextAutosizer.cpp:
+        Changed parameter from a pointer to a reference in the methods below.
+        (WebCore::TextAutosizer::processSubtree):
+        (WebCore::TextAutosizer::processCluster):
+        (WebCore::TextAutosizer::processContainer):
+        (WebCore::TextAutosizer::isNarrowDescendant):
+        (WebCore::TextAutosizer::isWiderDescendant):
+        (WebCore::TextAutosizer::isAutosizingCluster):
+        (WebCore::TextAutosizer::clusterShouldBeAutosized):
+        (WebCore::TextAutosizer::measureDescendantTextWidth):
+        * rendering/TextAutosizer.h: updated method prototypes.
+
 2013-02-09  Rafael Brandao  <rafael.lobo@openbossa.org>
 
         [TexMap] Separate classes per file in TextureMapperBackingStore.h
index 4dea1e3aa7713b3a4ff4df8703537662cc84a661..901b9d7c512725bfccd6679c6dae83f6720c2295 100644 (file)
@@ -123,24 +123,24 @@ bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
         cluster = cluster->containingBlock();
 
     TextAutosizingClusterInfo clusterInfo(cluster);
-    processCluster(&clusterInfo, container, layoutRoot, windowInfo);
+    processCluster(clusterInfo, container, layoutRoot, windowInfo);
     return true;
 }
 
-void TextAutosizer::processCluster(TextAutosizingClusterInfo* clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
+void TextAutosizer::processCluster(TextAutosizingClusterInfo& clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
 {
     // Many pages set a max-width on their content. So especially for the
     // RenderView, instead of just taking the width of |cluster| we find
     // the lowest common ancestor of the first and last descendant text node of
     // the cluster (i.e. the deepest wrapper block that contains all the text),
     // and use its width instead.
-    clusterInfo->blockContainingAllText = findDeepestBlockContainingAllText(clusterInfo->root);
-    float textWidth = clusterInfo->blockContainingAllText->contentLogicalWidth();
+    clusterInfo.blockContainingAllText = findDeepestBlockContainingAllText(clusterInfo.root);
+    float textWidth = clusterInfo.blockContainingAllText->contentLogicalWidth();
 
     float multiplier = 1;
     if (clusterShouldBeAutosized(clusterInfo, textWidth)) {
-        int logicalWindowWidth = clusterInfo->root->isHorizontalWritingMode() ? windowInfo.windowSize.width() : windowInfo.windowSize.height();
-        int logicalLayoutWidth = clusterInfo->root->isHorizontalWritingMode() ? windowInfo.minLayoutSize.width() : windowInfo.minLayoutSize.height();
+        int logicalWindowWidth = clusterInfo.root->isHorizontalWritingMode() ? windowInfo.windowSize.width() : windowInfo.windowSize.height();
+        int logicalLayoutWidth = clusterInfo.root->isHorizontalWritingMode() ? windowInfo.minLayoutSize.width() : windowInfo.minLayoutSize.height();
         // Ignore box width in excess of the layout width, to avoid extreme multipliers.
         float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth);
 
@@ -152,7 +152,7 @@ void TextAutosizer::processCluster(TextAutosizingClusterInfo* clusterInfo, Rende
     processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo);
 }
 
-void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
+void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo& clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
 {
     ASSERT(isAutosizingContainer(container));
 
@@ -170,7 +170,7 @@ void TextAutosizer::processContainer(float multiplier, RenderBlock* container, T
             RenderBlock* descendantBlock = toRenderBlock(descendant);
             if (isAutosizingCluster(descendantBlock, clusterInfo)) {
                 TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
-                processCluster(&descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
+                processCluster(descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
             } else
                 processContainer(multiplier, descendantBlock, clusterInfo, descendantBlock, windowInfo);
         }
@@ -235,7 +235,7 @@ bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
     return true;
 }
 
-bool TextAutosizer::isNarrowDescendant(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo)
+bool TextAutosizer::isNarrowDescendant(const RenderBlock* renderer, TextAutosizingClusterInfo& parentClusterInfo)
 {
     ASSERT(isAutosizingContainer(renderer));
 
@@ -252,24 +252,24 @@ bool TextAutosizer::isNarrowDescendant(const RenderBlock* renderer, TextAutosizi
     // less than 50px narrower than the current limit.
     const float differenceFromMaxWidthDifference = 50;
     float contentWidth = renderer->contentLogicalWidth();
-    float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth();
+    float clusterTextWidth = parentClusterInfo.blockContainingAllText->contentLogicalWidth();
     float widthDifference = clusterTextWidth - contentWidth;
 
-    if (widthDifference - parentClusterInfo->maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference)
+    if (widthDifference - parentClusterInfo.maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference)
         return true;
 
-    parentClusterInfo->maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo->maxAllowedDifferenceFromTextWidth);
+    parentClusterInfo.maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo.maxAllowedDifferenceFromTextWidth);
     return false;
 }
 
-bool TextAutosizer::isWiderDescendant(const RenderBlock* renderer, const TextAutosizingClusterInfo* parentClusterInfo)
+bool TextAutosizer::isWiderDescendant(const RenderBlock* renderer, const TextAutosizingClusterInfo& parentClusterInfo)
 {
     ASSERT(isAutosizingContainer(renderer));
 
     // Autosizing containers that are wider than the |blockContainingAllText| of their enclosing
     // cluster are treated the same way as autosizing clusters to be autosized separately.
     float contentWidth = renderer->contentLogicalWidth();
-    float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth();
+    float clusterTextWidth = parentClusterInfo.blockContainingAllText->contentLogicalWidth();
     return contentWidth > clusterTextWidth;
 }
 
@@ -310,7 +310,7 @@ bool TextAutosizer::isIndependentDescendant(const RenderBlock* renderer)
     // containers, and probably flexboxes...
 }
 
-bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo)
+bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo& parentClusterInfo)
 {
     ASSERT(isAutosizingContainer(renderer));
 
@@ -410,7 +410,7 @@ bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container)
     return false;
 }
 
-bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo* clusterInfo, float blockWidth)
+bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo& clusterInfo, float blockWidth)
 {
     // Don't autosize clusters that contain less than 4 lines of text (in
     // practice less lines are required, since measureDescendantTextWidth
@@ -425,13 +425,13 @@ bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo* clusterI
     const float minLinesOfText = 4;
     float minTextWidth = blockWidth * minLinesOfText;
     float textWidth = 0;
-    measureDescendantTextWidth(clusterInfo->blockContainingAllText, clusterInfo, minTextWidth, textWidth);
+    measureDescendantTextWidth(clusterInfo.blockContainingAllText, clusterInfo, minTextWidth, textWidth);
     if (textWidth >= minTextWidth)
         return true;
     return false;
 }
 
-void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, float minTextWidth, float& textWidth)
+void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo& clusterInfo, float minTextWidth, float& textWidth)
 {
     bool skipLocalText = !containerShouldBeAutosized(container);
 
index c52301e4ad49edb6e5e47c8bff36aa11dd604fd9..537157e910b68e5b629998e92b4720f3cee8e34f 100644 (file)
@@ -61,23 +61,23 @@ private:
 
     explicit TextAutosizer(Document*);
 
-    void processCluster(TextAutosizingClusterInfo*, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
-    void processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo*, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
+    void processCluster(TextAutosizingClusterInfo&, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
+    void processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo&, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
 
     void setMultiplier(RenderObject*, float);
 
     static bool isAutosizingContainer(const RenderObject*);
-    static bool isNarrowDescendant(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo);
-    static bool isWiderDescendant(const RenderBlock*, const TextAutosizingClusterInfo* parentClusterInfo);
+    static bool isNarrowDescendant(const RenderBlock*, TextAutosizingClusterInfo& parentClusterInfo);
+    static bool isWiderDescendant(const RenderBlock*, const TextAutosizingClusterInfo& parentClusterInfo);
     static bool isIndependentDescendant(const RenderBlock*);
-    static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo);
+    static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo& parentClusterInfo);
 
     static bool containerShouldBeAutosized(const RenderBlock* container);
     static bool containerContainsOneOfTags(const RenderBlock* cluster, const Vector<QualifiedName>& tags);
     static bool containerIsRowOfLinks(const RenderObject* container);
     static bool contentHeightIsConstrained(const RenderBlock* container);
-    static bool clusterShouldBeAutosized(TextAutosizingClusterInfo*, float blockWidth);
-    static void measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo*, float minTextWidth, float& textWidth);
+    static bool clusterShouldBeAutosized(TextAutosizingClusterInfo&, float blockWidth);
+    static void measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo&, float minTextWidth, float& textWidth);
 
     // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
     static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const RenderObject*, const RenderObject* stayWithin);