Title: [139135] trunk/Source/WebCore
Revision
139135
Author
[email protected]
Date
2013-01-08 16:59:43 -0800 (Tue, 08 Jan 2013)

Log Message

Merge getLineAtIndex into RenderBlock::lineAtIndex
https://bugs.webkit.org/show_bug.cgi?id=106379

Reviewed by Eric Seidel.

getLineAtIndex can be merged into lineAtIndex, which was it's only caller.

No new tests, just refactoring.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::lineAtIndex):
(WebCore::RenderBlock::lineCount):
* rendering/RenderBlock.h:
(RenderBlock):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139134 => 139135)


--- trunk/Source/WebCore/ChangeLog	2013-01-09 00:47:13 UTC (rev 139134)
+++ trunk/Source/WebCore/ChangeLog	2013-01-09 00:59:43 UTC (rev 139135)
@@ -1,3 +1,20 @@
+2013-01-08  Elliott Sprehn  <[email protected]>
+
+        Merge getLineAtIndex into RenderBlock::lineAtIndex
+        https://bugs.webkit.org/show_bug.cgi?id=106379
+
+        Reviewed by Eric Seidel.
+
+        getLineAtIndex can be merged into lineAtIndex, which was it's only caller.
+
+        No new tests, just refactoring.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::lineAtIndex):
+        (WebCore::RenderBlock::lineCount):
+        * rendering/RenderBlock.h:
+        (RenderBlock):
+
 2013-01-08  Rafael Weinstein  <[email protected]>
 
         [HTMLTemplateElement] Allow <template> content to be inspected

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (139134 => 139135)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-09 00:47:13 UTC (rev 139134)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-09 00:59:43 UTC (rev 139135)
@@ -6558,28 +6558,6 @@
             && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERTICAL);
 }
 
-static RootInlineBox* getLineAtIndex(RenderBlock* block, int i, int& count)
-{
-    if (block->style()->visibility() == VISIBLE) {
-        if (block->childrenInline()) {
-            for (RootInlineBox* box = block->firstRootBox(); box; box = box->nextRootBox()) {
-                if (count++ == i)
-                    return box;
-            }
-        }
-        else {
-            for (RenderObject* obj = block->firstChild(); obj; obj = obj->nextSibling()) {
-                if (shouldCheckLines(obj)) {
-                    RootInlineBox *box = getLineAtIndex(toRenderBlock(obj), i, count);
-                    if (box)
-                        return box;
-                }
-            }
-        }
-    }
-    return 0;
-}
-
 static int getHeightForLineCount(RenderBlock* block, int l, bool includeBottom, int& count)
 {
     if (block->style()->visibility() == VISIBLE) {
@@ -6607,13 +6585,30 @@
     return -1;
 }
 
-RootInlineBox* RenderBlock::lineAtIndex(int i)
+RootInlineBox* RenderBlock::lineAtIndex(int i) const
 {
-    int count = 0;
-    return getLineAtIndex(this, i, count);
+    ASSERT(i >= 0);
+
+    if (style()->visibility() != VISIBLE)
+        return 0;
+
+    if (childrenInline()) {
+        for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
+            if (!i--)
+                return box;
+    } else {
+        for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
+            if (!shouldCheckLines(child))
+                continue;
+            if (RootInlineBox* box = toRenderBlock(child)->lineAtIndex(i))
+                return box;
+        }
+    }
+
+    return 0;
 }
 
-int RenderBlock::lineCount()
+int RenderBlock::lineCount() const
 {
     int count = 0;
     if (style()->visibility() == VISIBLE) {

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (139134 => 139135)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-01-09 00:47:13 UTC (rev 139134)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-01-09 00:59:43 UTC (rev 139135)
@@ -238,10 +238,10 @@
     RenderBlock* blockBeforeWithinSelectionRoot(LayoutSize& offset) const;
 
     LayoutRect logicalRectToPhysicalRect(const LayoutPoint& physicalPosition, const LayoutRect& logicalRect);
-        
+
     // Helper methods for computing line counts and heights for line counts.
-    RootInlineBox* lineAtIndex(int);
-    int lineCount();
+    RootInlineBox* lineAtIndex(int) const;
+    int lineCount() const;
     int heightForLineCount(int);
     void clearTruncation();
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to