Tidy up isIsolatedInline() and highestContainingIsolateWithinRoot()
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Apr 2014 19:39:22 +0000 (19:39 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Apr 2014 19:39:22 +0000 (19:39 +0000)
<http://webkit.org/b/131117>

Reviewed by Daniel Bates.

Based on review feedback for r166650.

* rendering/InlineIterator.h:
(WebCore::isIsolatedInline):
- Switch argument to a reference since it is never called with a
  nullptr.
(WebCore::highestContainingIsolateWithinRoot):
- Switch first argument to a reference since it's never a
  nullptr.
- Use nullptr for pointer initialization.
- Switch while() loop to for() loop. Pass reference to
  isIsolatedInline().
(WebCore::numberOfIsolateAncestors):
- Switch while() loop to for() loop. Pass reference to
  isIsolatedInline().
* rendering/RenderBlockLineLayout.cpp:
(WebCore::constructBidiRunsForSegment):
- Rename startObj to startObject.
- No longer need to pass the address of startObject here.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineIterator.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 5076b936a83baeea3fadc7e98187caf2eb808a87..86c6449a3bcb839576417002ab2869b9ae281e74 100644 (file)
@@ -1,3 +1,30 @@
+2014-04-17  David Kilzer  <ddkilzer@apple.com>
+
+        Tidy up isIsolatedInline() and highestContainingIsolateWithinRoot()
+        <http://webkit.org/b/131117>
+
+        Reviewed by Daniel Bates.
+
+        Based on review feedback for r166650.
+
+        * rendering/InlineIterator.h:
+        (WebCore::isIsolatedInline):
+        - Switch argument to a reference since it is never called with a
+          nullptr.
+        (WebCore::highestContainingIsolateWithinRoot):
+        - Switch first argument to a reference since it's never a
+          nullptr.
+        - Use nullptr for pointer initialization.
+        - Switch while() loop to for() loop. Pass reference to
+          isIsolatedInline().
+        (WebCore::numberOfIsolateAncestors):
+        - Switch while() loop to for() loop. Pass reference to
+          isIsolatedInline().
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::constructBidiRunsForSegment):
+        - Rename startObj to startObject.
+        - No longer need to pass the address of startObject here.
+
 2014-04-17  Andreas Kling  <akling@apple.com>
 
         Log number of bytes reclaimed at each step of memory pressure relief.
index 07ea7963231686425a36b5875aab3dc07b26f683..b876d393bab02c16ea20c233bd630ef2e3c02854 100644 (file)
@@ -442,35 +442,28 @@ inline void InlineBidiResolver::increment()
     m_current.increment(this);
 }
 
-static inline bool isIsolatedInline(RenderObject* object)
+static inline bool isIsolatedInline(RenderObject& object)
 {
-    ASSERT(object);
-    return object->isRenderInline() && isIsolated(object->style().unicodeBidi());
+    return object.isRenderInline() && isIsolated(object.style().unicodeBidi());
 }
 
-static inline RenderObject* highestContainingIsolateWithinRoot(RenderObject* object, RenderObject* root)
+static inline RenderObject* highestContainingIsolateWithinRoot(RenderObject& initialObject, RenderObject* root)
 {
-    ASSERT(object);
-    RenderObject* containingIsolateObject = 0;
-    while (object && object != root) {
-        if (isIsolatedInline(object))
+    RenderObject* containingIsolateObject = nullptr;
+    for (RenderObject* object = &initialObject; object && object != root; object = object->parent()) {
+        if (isIsolatedInline(*object))
             containingIsolateObject = object;
-
-        object = object->parent();
     }
     return containingIsolateObject;
 }
 
 static inline unsigned numberOfIsolateAncestors(const InlineIterator& iter)
 {
-    RenderObject* object = iter.renderer();
-    if (!object)
-        return 0;
     unsigned count = 0;
-    while (object && object != iter.root()) {
-        if (isIsolatedInline(object))
+    typedef RenderObject* RenderObjectPtr;
+    for (RenderObjectPtr object = iter.renderer(), root = iter.root(); object && object != root; object = object->parent()) {
+        if (isIsolatedInline(*object))
             count++;
-        object = object->parent();
     }
     return count;
 }
index 07e9c8a6863da6b0dad3db122d78fd0a4047e3e0..112d972280e0b4b665daa9855a19099114b34b45 100644 (file)
@@ -852,14 +852,14 @@ static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver,
         BidiRun* isolatedRun = topResolver.isolatedRuns().last();
         topResolver.isolatedRuns().removeLast();
 
-        RenderObject& startObj = isolatedRun->renderer();
+        RenderObject& startObject = isolatedRun->renderer();
 
         // Only inlines make sense with unicode-bidi: isolate (blocks are already isolated).
         // FIXME: Because enterIsolate is not passed a RenderObject, we have to crawl up the
         // tree to see which parent inline is the isolate. We could change enterIsolate
         // to take a RenderObject and do this logic there, but that would be a layering
         // violation for BidiResolver (which knows nothing about RenderObject).
-        RenderInline* isolatedInline = toRenderInline(highestContainingIsolateWithinRoot(&startObj, currentRoot));
+        RenderInline* isolatedInline = toRenderInline(highestContainingIsolateWithinRoot(startObject, currentRoot));
         ASSERT(isolatedInline);
 
         InlineBidiResolver isolatedResolver;
@@ -873,12 +873,12 @@ static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver,
         }
         isolatedResolver.setStatus(BidiStatus(direction, isOverride(unicodeBidi)));
 
-        setUpResolverToResumeInIsolate(isolatedResolver, isolatedInline, &startObj);
+        setUpResolverToResumeInIsolate(isolatedResolver, isolatedInline, &startObject);
 
         // The starting position is the beginning of the first run within the isolate that was identified
         // during the earlier call to createBidiRunsForLine. This can be but is not necessarily the
         // first run within the isolate.
-        InlineIterator iter = InlineIterator(isolatedInline, &startObj, isolatedRun->m_start);
+        InlineIterator iter = InlineIterator(isolatedInline, &startObject, isolatedRun->m_start);
         isolatedResolver.setPositionIgnoringNestedIsolates(iter);
 
         // We stop at the next end of line; we may re-enter this isolate in the next call to constructBidiRuns().