OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the select element layoutObject in WebCore. | 2 * This file is part of the select element layoutObject in WebCore. |
3 * | 3 * |
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
6 * All rights reserved. | 6 * All rights reserved. |
7 * (C) 2009 Torch Mobile Inc. All rights reserved. | 7 * (C) 2009 Torch Mobile Inc. All rights reserved. |
8 * (http://www.torchmobile.com/) | 8 * (http://www.torchmobile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 LayoutMenuList::LayoutMenuList(Element* element) | 41 LayoutMenuList::LayoutMenuList(Element* element) |
42 : LayoutFlexibleBox(element), | 42 : LayoutFlexibleBox(element), |
43 m_buttonText(nullptr), | 43 m_buttonText(nullptr), |
44 m_innerBlock(nullptr), | 44 m_innerBlock(nullptr), |
45 m_isEmpty(false), | 45 m_isEmpty(false), |
46 m_hasUpdatedActiveOption(false), | 46 m_hasUpdatedActiveOption(false), |
47 m_innerBlockHeight(LayoutUnit()), | 47 m_innerBlockHeight(LayoutUnit()), |
48 m_optionsWidth(0), | 48 m_optionsWidth(0), |
49 m_lastActiveIndex(-1) { | 49 m_lastActiveIndex(-1) { |
50 ASSERT(isHTMLSelectElement(element)); | 50 DCHECK(isHTMLSelectElement(element)); |
51 } | 51 } |
52 | 52 |
53 LayoutMenuList::~LayoutMenuList() {} | 53 LayoutMenuList::~LayoutMenuList() {} |
54 | 54 |
55 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no | 55 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no |
56 // insertion point to prevent children from rendering. | 56 // insertion point to prevent children from rendering. |
57 bool LayoutMenuList::isChildAllowed(LayoutObject* object, | 57 bool LayoutMenuList::isChildAllowed(LayoutObject* object, |
58 const ComputedStyle&) const { | 58 const ComputedStyle&) const { |
59 return object->isAnonymous() && !object->isLayoutFullScreen(); | 59 return object->isAnonymous() && !object->isLayoutFullScreen(); |
60 } | 60 } |
61 | 61 |
62 void LayoutMenuList::createInnerBlock() { | 62 void LayoutMenuList::createInnerBlock() { |
63 if (m_innerBlock) { | 63 if (m_innerBlock) { |
64 ASSERT(firstChild() == m_innerBlock); | 64 DCHECK_EQ(firstChild(), m_innerBlock); |
65 ASSERT(!m_innerBlock->nextSibling()); | 65 DCHECK(!m_innerBlock->nextSibling()); |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 // Create an anonymous block. | 69 // Create an anonymous block. |
70 ASSERT(!firstChild()); | 70 DCHECK(!firstChild()); |
71 m_innerBlock = createAnonymousBlock(); | 71 m_innerBlock = createAnonymousBlock(); |
72 | 72 |
73 m_buttonText = LayoutText::createEmptyAnonymous(document()); | 73 m_buttonText = LayoutText::createEmptyAnonymous(document()); |
74 // We need to set the text explicitly though it was specified in the | 74 // We need to set the text explicitly though it was specified in the |
75 // constructor because LayoutText doesn't refer to the text | 75 // constructor because LayoutText doesn't refer to the text |
76 // specified in the constructor in a case of re-transforming. | 76 // specified in the constructor in a case of re-transforming. |
77 m_buttonText->setStyle(mutableStyle()); | 77 m_buttonText->setStyle(mutableStyle()); |
78 m_innerBlock->addChild(m_buttonText); | 78 m_innerBlock->addChild(m_buttonText); |
79 | 79 |
80 adjustInnerStyle(); | 80 adjustInnerStyle(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 HTMLSelectElement* LayoutMenuList::selectElement() const { | 129 HTMLSelectElement* LayoutMenuList::selectElement() const { |
130 return toHTMLSelectElement(node()); | 130 return toHTMLSelectElement(node()); |
131 } | 131 } |
132 | 132 |
133 void LayoutMenuList::addChild(LayoutObject* newChild, | 133 void LayoutMenuList::addChild(LayoutObject* newChild, |
134 LayoutObject* beforeChild) { | 134 LayoutObject* beforeChild) { |
135 m_innerBlock->addChild(newChild, beforeChild); | 135 m_innerBlock->addChild(newChild, beforeChild); |
136 ASSERT(m_innerBlock == firstChild()); | 136 DCHECK_EQ(m_innerBlock, firstChild()); |
137 | 137 |
138 if (AXObjectCache* cache = document().existingAXObjectCache()) | 138 if (AXObjectCache* cache = document().existingAXObjectCache()) |
139 cache->childrenChanged(this); | 139 cache->childrenChanged(this); |
140 } | 140 } |
141 | 141 |
142 void LayoutMenuList::removeChild(LayoutObject* oldChild) { | 142 void LayoutMenuList::removeChild(LayoutObject* oldChild) { |
143 if (oldChild == m_innerBlock || !m_innerBlock) { | 143 if (oldChild == m_innerBlock || !m_innerBlock) { |
144 LayoutFlexibleBox::removeChild(oldChild); | 144 LayoutFlexibleBox::removeChild(oldChild); |
145 m_innerBlock = nullptr; | 145 m_innerBlock = nullptr; |
146 } else { | 146 } else { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 if (selectedCount == 1) { | 202 if (selectedCount == 1) { |
203 text = selectedOptionElement->textIndentedToRespectGroupLabel(); | 203 text = selectedOptionElement->textIndentedToRespectGroupLabel(); |
204 m_optionStyle = selectedOptionElement->mutableComputedStyle(); | 204 m_optionStyle = selectedOptionElement->mutableComputedStyle(); |
205 } else { | 205 } else { |
206 Locale& locale = select->locale(); | 206 Locale& locale = select->locale(); |
207 String localizedNumberString = | 207 String localizedNumberString = |
208 locale.convertToLocalizedNumber(String::number(selectedCount)); | 208 locale.convertToLocalizedNumber(String::number(selectedCount)); |
209 text = locale.queryString(WebLocalizedString::SelectMenuListText, | 209 text = locale.queryString(WebLocalizedString::SelectMenuListText, |
210 localizedNumberString); | 210 localizedNumberString); |
211 ASSERT(!m_optionStyle); | 211 DCHECK(!m_optionStyle); |
212 } | 212 } |
213 } else { | 213 } else { |
214 if (option) { | 214 if (option) { |
215 text = option->textIndentedToRespectGroupLabel(); | 215 text = option->textIndentedToRespectGroupLabel(); |
216 m_optionStyle = option->mutableComputedStyle(); | 216 m_optionStyle = option->mutableComputedStyle(); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 setText(text.stripWhiteSpace()); | 220 setText(text.stripWhiteSpace()); |
221 | 221 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 314 |
315 LayoutUnit LayoutMenuList::clientPaddingLeft() const { | 315 LayoutUnit LayoutMenuList::clientPaddingLeft() const { |
316 return paddingLeft() + m_innerBlock->paddingLeft(); | 316 return paddingLeft() + m_innerBlock->paddingLeft(); |
317 } | 317 } |
318 | 318 |
319 LayoutUnit LayoutMenuList::clientPaddingRight() const { | 319 LayoutUnit LayoutMenuList::clientPaddingRight() const { |
320 return paddingRight() + m_innerBlock->paddingRight(); | 320 return paddingRight() + m_innerBlock->paddingRight(); |
321 } | 321 } |
322 | 322 |
323 } // namespace blink | 323 } // namespace blink |
OLD | NEW |