Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutListItem.cpp

Issue 2394263004: Reformat comments in core/layout up until LayoutMultiColumnFlowThread (Closed)
Patch Set: Rebase w/HEAD Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 static bool isList(const Node& node) { 112 static bool isList(const Node& node) {
113 return isHTMLUListElement(node) || isHTMLOListElement(node); 113 return isHTMLUListElement(node) || isHTMLOListElement(node);
114 } 114 }
115 115
116 // Returns the enclosing list with respect to the DOM order. 116 // Returns the enclosing list with respect to the DOM order.
117 static Node* enclosingList(const LayoutListItem* listItem) { 117 static Node* enclosingList(const LayoutListItem* listItem) {
118 Node* listItemNode = listItem->node(); 118 Node* listItemNode = listItem->node();
119 if (!listItemNode) 119 if (!listItemNode)
120 return nullptr; 120 return nullptr;
121 Node* firstNode = nullptr; 121 Node* firstNode = nullptr;
122 // We use parentNode because the enclosing list could be a ShadowRoot that's n ot Element. 122 // We use parentNode because the enclosing list could be a ShadowRoot that's
123 // not Element.
123 for (Node* parent = FlatTreeTraversal::parent(*listItemNode); parent; 124 for (Node* parent = FlatTreeTraversal::parent(*listItemNode); parent;
124 parent = FlatTreeTraversal::parent(*parent)) { 125 parent = FlatTreeTraversal::parent(*parent)) {
125 if (isList(*parent)) 126 if (isList(*parent))
126 return parent; 127 return parent;
127 if (!firstNode) 128 if (!firstNode)
128 firstNode = parent; 129 firstNode = parent;
129 } 130 }
130 131
131 // If there's no actual <ul> or <ol> list element, then the first found 132 // If there's no actual <ul> or <ol> list element, then the first found
132 // node acts as our list for purposes of determining what other list items 133 // node acts as our list for purposes of determining what other list items
(...skipping 17 matching lines...) Expand all
150 // We've found a nested, independent list: nothing to do here. 151 // We've found a nested, independent list: nothing to do here.
151 current = 152 current =
152 LayoutTreeBuilderTraversal::nextSkippingChildren(*current, listNode); 153 LayoutTreeBuilderTraversal::nextSkippingChildren(*current, listNode);
153 continue; 154 continue;
154 } 155 }
155 156
156 LayoutObject* layoutObject = current->layoutObject(); 157 LayoutObject* layoutObject = current->layoutObject();
157 if (layoutObject && layoutObject->isListItem()) 158 if (layoutObject && layoutObject->isListItem())
158 return toLayoutListItem(layoutObject); 159 return toLayoutListItem(layoutObject);
159 160
160 // FIXME: Can this be optimized to skip the children of the elements without a layoutObject? 161 // FIXME: Can this be optimized to skip the children of the elements without
162 // a layoutObject?
161 current = LayoutTreeBuilderTraversal::next(*current, listNode); 163 current = LayoutTreeBuilderTraversal::next(*current, listNode);
162 } 164 }
163 165
164 return nullptr; 166 return nullptr;
165 } 167 }
166 168
167 // Returns the previous list item with respect to the DOM order. 169 // Returns the previous list item with respect to the DOM order.
168 static LayoutListItem* previousListItem(const Node* listNode, 170 static LayoutListItem* previousListItem(const Node* listNode,
169 const LayoutListItem* item) { 171 const LayoutListItem* item) {
170 Node* current = item->node(); 172 Node* current = item->node();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 LayoutObject* result = parent->slowFirstChild(); 295 LayoutObject* result = parent->slowFirstChild();
294 while (result && result->isListMarker()) 296 while (result && result->isListMarker())
295 result = result->nextSibling(); 297 result = result->nextSibling();
296 return result; 298 return result;
297 } 299 }
298 300
299 bool LayoutListItem::updateMarkerLocation() { 301 bool LayoutListItem::updateMarkerLocation() {
300 ASSERT(m_marker); 302 ASSERT(m_marker);
301 303
302 LayoutObject* markerParent = m_marker->parent(); 304 LayoutObject* markerParent = m_marker->parent();
303 // list-style-position:inside makes the ::marker pseudo an ordinary position:s tatic element that should be attached to LayoutListItem block. 305 // list-style-position:inside makes the ::marker pseudo an ordinary
306 // position:static element that should be attached to LayoutListItem block.
304 LayoutObject* lineBoxParent = 307 LayoutObject* lineBoxParent =
305 m_marker->isInside() ? this : getParentOfFirstLineBox(this, m_marker); 308 m_marker->isInside() ? this : getParentOfFirstLineBox(this, m_marker);
306 if (!lineBoxParent) { 309 if (!lineBoxParent) {
307 // If the marker is currently contained inside an anonymous box, then we 310 // If the marker is currently contained inside an anonymous box, then we
308 // are the only item in that anonymous box (since no line box parent was 311 // are the only item in that anonymous box (since no line box parent was
309 // found). It's ok to just leave the marker where it is in this case. 312 // found). It's ok to just leave the marker where it is in this case.
310 if (markerParent && markerParent->isAnonymousBlock()) 313 if (markerParent && markerParent->isAnonymousBlock())
311 lineBoxParent = markerParent; 314 lineBoxParent = markerParent;
312 else 315 else
313 lineBoxParent = this; 316 lineBoxParent = this;
314 } 317 }
315 318
316 if (markerParent != lineBoxParent) { 319 if (markerParent != lineBoxParent) {
317 m_marker->remove(); 320 m_marker->remove();
318 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); 321 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
319 // TODO(rhogan): lineBoxParent and markerParent may be deleted by addChild, so they are not safe to reference here. 322 // TODO(rhogan): lineBoxParent and markerParent may be deleted by addChild,
320 // Once we have a safe way of referencing them delete markerParent if it is an empty anonymous block. 323 // so they are not safe to reference here.
324 // Once we have a safe way of referencing them delete markerParent if it is
325 // an empty anonymous block.
321 m_marker->updateMarginsAndContent(); 326 m_marker->updateMarginsAndContent();
322 return true; 327 return true;
323 } 328 }
324 329
325 return false; 330 return false;
326 } 331 }
327 332
328 void LayoutListItem::addOverflowFromChildren() { 333 void LayoutListItem::addOverflowFromChildren() {
329 LayoutBlockFlow::addOverflowFromChildren(); 334 LayoutBlockFlow::addOverflowFromChildren();
330 positionListMarker(); 335 positionListMarker();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 ASSERT(listNode); 523 ASSERT(listNode);
519 524
520 bool isListReversed = false; 525 bool isListReversed = false;
521 HTMLOListElement* oListElement = 526 HTMLOListElement* oListElement =
522 isHTMLOListElement(listNode) ? toHTMLOListElement(listNode) : 0; 527 isHTMLOListElement(listNode) ? toHTMLOListElement(listNode) : 0;
523 if (oListElement) { 528 if (oListElement) {
524 oListElement->itemCountChanged(); 529 oListElement->itemCountChanged();
525 isListReversed = oListElement->isReversed(); 530 isListReversed = oListElement->isReversed();
526 } 531 }
527 532
528 // FIXME: The n^2 protection below doesn't help if the elements were inserted after the 533 // FIXME: The n^2 protection below doesn't help if the elements were inserted
529 // the list had already been displayed. 534 // after the the list had already been displayed.
530 535
531 // Avoid an O(n^2) walk over the children below when they're all known to be a ttaching. 536 // Avoid an O(n^2) walk over the children below when they're all known to be
537 // attaching.
532 if (listNode->needsAttach()) 538 if (listNode->needsAttach())
533 return; 539 return;
534 540
535 for (LayoutListItem* item = 541 for (LayoutListItem* item =
536 previousOrNextItem(isListReversed, listNode, this); 542 previousOrNextItem(isListReversed, listNode, this);
537 item; item = previousOrNextItem(isListReversed, listNode, item)) { 543 item; item = previousOrNextItem(isListReversed, listNode, item)) {
538 if (!item->m_isValueUpToDate) { 544 if (!item->m_isValueUpToDate) {
539 // If an item has been marked for update before, we can safely 545 // If an item has been marked for update before, we can safely
540 // assume that all the following ones have too. 546 // assume that all the following ones have too.
541 // This gives us the opportunity to stop here and avoid 547 // This gives us the opportunity to stop here and avoid
542 // marking the same nodes again. 548 // marking the same nodes again.
543 break; 549 break;
544 } 550 }
545 item->updateValue(); 551 item->updateValue();
546 } 552 }
547 } 553 }
548 554
549 } // namespace blink 555 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutListItem.h ('k') | third_party/WebKit/Source/core/layout/LayoutListMarker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698