Index: third_party/WebKit/Source/core/layout/CounterNode.cpp |
diff --git a/third_party/WebKit/Source/core/layout/CounterNode.cpp b/third_party/WebKit/Source/core/layout/CounterNode.cpp |
index 0437f885d3c1484a22b8659ba796bbe67a2fa6ad..9df70d54001ed6948040953b107340321d1a2f99 100644 |
--- a/third_party/WebKit/Source/core/layout/CounterNode.cpp |
+++ b/third_party/WebKit/Source/core/layout/CounterNode.cpp |
@@ -42,13 +42,15 @@ CounterNode::CounterNode(LayoutObject& o, bool hasResetType, int value) |
m_lastChild(nullptr) {} |
CounterNode::~CounterNode() { |
- // Ideally this would be an assert and this would never be reached. In reality this happens a lot |
- // so we need to handle these cases. The node is still connected to the tree so we need to detach it. |
+ // Ideally this would be an assert and this would never be reached. In reality |
+ // this happens a lot so we need to handle these cases. The node is still |
+ // connected to the tree so we need to detach it. |
if (m_parent || m_previousSibling || m_nextSibling || m_firstChild || |
m_lastChild) { |
CounterNode* oldParent = nullptr; |
CounterNode* oldPreviousSibling = nullptr; |
- // Instead of calling removeChild() we do this safely as the tree is likely broken if we get here. |
+ // Instead of calling removeChild() we do this safely as the tree is likely |
+ // broken if we get here. |
if (m_parent) { |
if (m_parent->m_firstChild == this) |
m_parent->m_firstChild = m_nextSibling; |
@@ -90,59 +92,50 @@ CounterNode::~CounterNode() { |
} |
PassRefPtr<CounterNode> CounterNode::create(LayoutObject& owner, |
- bool hasResetType, |
- int value) { |
+ bool hasResetType, int value) { |
return adoptRef(new CounterNode(owner, hasResetType, value)); |
} |
CounterNode* CounterNode::nextInPreOrderAfterChildren( |
const CounterNode* stayWithin) const { |
- if (this == stayWithin) |
- return nullptr; |
+ if (this == stayWithin) return nullptr; |
const CounterNode* current = this; |
CounterNode* next = current->m_nextSibling; |
for (; !next; next = current->m_nextSibling) { |
current = current->m_parent; |
- if (!current || current == stayWithin) |
- return nullptr; |
+ if (!current || current == stayWithin) return nullptr; |
} |
return next; |
} |
CounterNode* CounterNode::nextInPreOrder(const CounterNode* stayWithin) const { |
- if (CounterNode* next = m_firstChild) |
- return next; |
+ if (CounterNode* next = m_firstChild) return next; |
return nextInPreOrderAfterChildren(stayWithin); |
} |
CounterNode* CounterNode::lastDescendant() const { |
CounterNode* last = m_lastChild; |
- if (!last) |
- return nullptr; |
+ if (!last) return nullptr; |
- while (CounterNode* lastChild = last->m_lastChild) |
- last = lastChild; |
+ while (CounterNode* lastChild = last->m_lastChild) last = lastChild; |
return last; |
} |
CounterNode* CounterNode::previousInPreOrder() const { |
CounterNode* previous = m_previousSibling; |
- if (!previous) |
- return m_parent; |
+ if (!previous) return m_parent; |
- while (CounterNode* lastChild = previous->m_lastChild) |
- previous = lastChild; |
+ while (CounterNode* lastChild = previous->m_lastChild) previous = lastChild; |
return previous; |
} |
int CounterNode::computeCountInParent() const { |
int increment = actsAsReset() ? 0 : m_value; |
- if (m_previousSibling) |
- return m_previousSibling->m_countInParent + increment; |
+ if (m_previousSibling) return m_previousSibling->m_countInParent + increment; |
ASSERT(m_parent->m_firstChild == this); |
return m_parent->m_value + increment; |
} |
@@ -203,8 +196,10 @@ void CounterNode::removeLayoutObject(LayoutCounter* value) { |
void CounterNode::resetLayoutObjects() { |
while (m_rootLayoutObject) |
- m_rootLayoutObject |
- ->invalidate(); // This makes m_rootLayoutObject point to the next layoutObject if any since it disconnects the m_rootLayoutObject from this. |
+ m_rootLayoutObject->invalidate(); // This makes m_rootLayoutObject point to |
ikilpatrick
2016/10/04 16:39:02
nit. comment should be above line.
|
+ // the next layoutObject if any since it |
+ // disconnects the m_rootLayoutObject |
+ // from this. |
} |
void CounterNode::resetThisAndDescendantsLayoutObjects() { |
@@ -219,24 +214,23 @@ void CounterNode::recount() { |
for (CounterNode* node = this; node; node = node->m_nextSibling) { |
int oldCount = node->m_countInParent; |
int newCount = node->computeCountInParent(); |
- if (oldCount == newCount) |
- break; |
+ if (oldCount == newCount) break; |
node->m_countInParent = newCount; |
node->resetThisAndDescendantsLayoutObjects(); |
} |
} |
-void CounterNode::insertAfter(CounterNode* newChild, |
- CounterNode* refChild, |
+void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, |
const AtomicString& identifier) { |
ASSERT(newChild); |
ASSERT(!newChild->m_parent); |
ASSERT(!newChild->m_previousSibling); |
ASSERT(!newChild->m_nextSibling); |
- // If the refChild is not our child we can not complete the request. This hardens against bugs in LayoutCounter. |
- // When layoutObjects are reparented it may request that we insert counter nodes improperly. |
- if (refChild && refChild->m_parent != this) |
- return; |
+ // If the refChild is not our child we can not complete the request. This |
+ // hardens against bugs in LayoutCounter. |
+ // When layoutObjects are reparented it may request that we insert counter |
+ // nodes improperly. |
+ if (refChild && refChild->m_parent != this) return; |
if (newChild->m_hasResetType) { |
while (m_lastChild != refChild) |
@@ -268,33 +262,33 @@ void CounterNode::insertAfter(CounterNode* newChild, |
if (!newChild->m_firstChild || newChild->m_hasResetType) { |
newChild->m_countInParent = newChild->computeCountInParent(); |
newChild->resetThisAndDescendantsLayoutObjects(); |
- if (next) |
- next->recount(); |
+ if (next) next->recount(); |
return; |
} |
- // The code below handles the case when a formerly root increment counter is loosing its root position |
- // and therefore its children become next siblings. |
+ // The code below handles the case when a formerly root increment counter is |
+ // loosing its root position and therefore its children become next siblings. |
CounterNode* last = newChild->m_lastChild; |
CounterNode* first = newChild->m_firstChild; |
if (first) { |
ASSERT(last); |
newChild->m_nextSibling = first; |
- if (m_lastChild == newChild) |
- m_lastChild = last; |
+ if (m_lastChild == newChild) m_lastChild = last; |
first->m_previousSibling = newChild; |
- // The case when the original next sibling of the inserted node becomes a child of |
- // one of the former children of the inserted node is not handled as it is believed |
- // to be impossible since: |
- // 1. if the increment counter node lost it's root position as a result of another |
- // counter node being created, it will be inserted as the last child so next is null. |
- // 2. if the increment counter node lost it's root position as a result of a layoutObject being |
- // inserted into the document's layout tree, all its former children counters are attached |
- // to children of the inserted layoutObject and hence cannot be in scope for counter nodes |
- // attached to layoutObjects that were already in the document's layout tree. |
+ // The case when the original next sibling of the inserted node becomes a |
+ // child of one of the former children of the inserted node is not handled |
+ // as it is believed to be impossible since: |
+ // 1. if the increment counter node lost it's root position as a result of |
+ // another counter node being created, it will be inserted as the last |
+ // child so next is null. |
+ // 2. if the increment counter node lost it's root position as a result of a |
+ // layoutObject being inserted into the document's layout tree, all its |
+ // former children counters are attached to children of the inserted |
+ // layoutObject and hence cannot be in scope for counter nodes attached |
+ // to layoutObjects that were already in the document's layout tree. |
last->m_nextSibling = next; |
if (next) { |
ASSERT(next->m_previousSibling == newChild); |