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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLLIElement.cpp

Issue 1759173002: [Layout API] Create api/LayoutLIItem and use it in html/HTMLLIElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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) 2006, 2007, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "core/html/HTMLLIElement.h" 23 #include "core/html/HTMLLIElement.h"
24 24
25 #include "core/CSSPropertyNames.h" 25 #include "core/CSSPropertyNames.h"
26 #include "core/CSSValueKeywords.h" 26 #include "core/CSSValueKeywords.h"
27 #include "core/HTMLNames.h" 27 #include "core/HTMLNames.h"
28 #include "core/dom/LayoutTreeBuilderTraversal.h" 28 #include "core/dom/LayoutTreeBuilderTraversal.h"
29 #include "core/layout/LayoutListItem.h" 29 #include "core/layout/LayoutListItem.h"
30 #include "core/layout/api/LayoutLIItem.h"
30 31
31 namespace blink { 32 namespace blink {
32 33
33 using namespace HTMLNames; 34 using namespace HTMLNames;
34 35
35 inline HTMLLIElement::HTMLLIElement(Document& document) 36 inline HTMLLIElement::HTMLLIElement(Document& document)
36 : HTMLElement(liTag, document) 37 : HTMLElement(liTag, document)
37 { 38 {
38 } 39 }
39 40
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } else { 89 } else {
89 HTMLElement::parseAttribute(name, oldValue, value); 90 HTMLElement::parseAttribute(name, oldValue, value);
90 } 91 }
91 } 92 }
92 93
93 void HTMLLIElement::attach(const AttachContext& context) 94 void HTMLLIElement::attach(const AttachContext& context)
94 { 95 {
95 HTMLElement::attach(context); 96 HTMLElement::attach(context);
96 97
97 if (layoutObject() && layoutObject()->isListItem()) { 98 if (layoutObject() && layoutObject()->isListItem()) {
98 LayoutListItem* listItemLayoutObject = toLayoutListItem(layoutObject()); 99 LayoutLIItem liLayoutItem = LayoutLIItem(toLayoutListItem(layoutObject() ));
99 100
100 ASSERT(!document().childNeedsDistributionRecalc()); 101 ASSERT(!document().childNeedsDistributionRecalc());
101 102
102 // Find the enclosing list node. 103 // Find the enclosing list node.
103 Element* listNode = 0; 104 Element* listNode = 0;
104 Element* current = this; 105 Element* current = this;
105 while (!listNode) { 106 while (!listNode) {
106 current = LayoutTreeBuilderTraversal::parentElement(*current); 107 current = LayoutTreeBuilderTraversal::parentElement(*current);
107 if (!current) 108 if (!current)
108 break; 109 break;
109 if (isHTMLUListElement(*current) || isHTMLOListElement(*current)) 110 if (isHTMLUListElement(*current) || isHTMLOListElement(*current))
110 listNode = current; 111 listNode = current;
111 } 112 }
112 113
113 // If we are not in a list, tell the layoutObject so it can position us inside. 114 // If we are not in a list, tell the layoutObject so it can position us inside.
114 // We don't want to change our style to say "inside" since that would af fect nested nodes. 115 // We don't want to change our style to say "inside" since that would af fect nested nodes.
115 if (!listNode) 116 if (!listNode)
116 listItemLayoutObject->setNotInList(true); 117 liLayoutItem.setNotInList(true);
117 118
118 parseValue(fastGetAttribute(valueAttr)); 119 parseValue(fastGetAttribute(valueAttr));
119 } 120 }
120 } 121 }
121 122
122 inline void HTMLLIElement::parseValue(const AtomicString& value) 123 inline void HTMLLIElement::parseValue(const AtomicString& value)
123 { 124 {
124 ASSERT(layoutObject() && layoutObject()->isListItem()); 125 ASSERT(layoutObject() && layoutObject()->isListItem());
125 126
126 bool valueOK; 127 bool valueOK;
127 int requestedValue = value.toInt(&valueOK); 128 int requestedValue = value.toInt(&valueOK);
128 if (valueOK) 129 if (valueOK)
129 toLayoutListItem(layoutObject())->setExplicitValue(requestedValue); 130 toLayoutListItem(layoutObject())->setExplicitValue(requestedValue);
130 else 131 else
131 toLayoutListItem(layoutObject())->clearExplicitValue(); 132 toLayoutListItem(layoutObject())->clearExplicitValue();
132 } 133 }
133 134
134 } // namespace blink 135 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/layout/api/LayoutItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698