| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the select element renderer in WebCore. | 2 * This file is part of the select element renderer 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. All rights reserv
ed. | 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 // Create an anonymous block. | 94 // Create an anonymous block. |
| 95 ASSERT(!firstChild()); | 95 ASSERT(!firstChild()); |
| 96 m_innerBlock = createAnonymousBlock(); | 96 m_innerBlock = createAnonymousBlock(); |
| 97 adjustInnerStyle(); | 97 adjustInnerStyle(); |
| 98 RenderFlexibleBox::addChild(m_innerBlock); | 98 RenderFlexibleBox::addChild(m_innerBlock); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void RenderMenuList::adjustInnerStyle() | 101 void RenderMenuList::adjustInnerStyle() |
| 102 { | 102 { |
| 103 RenderStyle* innerStyle = m_innerBlock->style(); | 103 RenderStyle& innerStyle = m_innerBlock->mutableStyleRef(); |
| 104 innerStyle->setFlexGrow(1); | 104 innerStyle.setFlexGrow(1); |
| 105 innerStyle->setFlexShrink(1); | 105 innerStyle.setFlexShrink(1); |
| 106 // Use margin:auto instead of align-items:center to get safe centering, i.e. | 106 // Use margin:auto instead of align-items:center to get safe centering, i.e. |
| 107 // when the content overflows, treat it the same as align-items: flex-start. | 107 // when the content overflows, treat it the same as align-items: flex-start. |
| 108 // But we only do that for the cases where html.css would otherwise use cent
er. | 108 // But we only do that for the cases where html.css would otherwise use cent
er. |
| 109 if (style()->alignItems() == ItemPositionCenter) { | 109 if (style()->alignItems() == ItemPositionCenter) { |
| 110 innerStyle->setMarginTop(Length()); | 110 innerStyle.setMarginTop(Length()); |
| 111 innerStyle->setMarginBottom(Length()); | 111 innerStyle.setMarginBottom(Length()); |
| 112 innerStyle->setAlignSelf(ItemPositionFlexStart); | 112 innerStyle.setAlignSelf(ItemPositionFlexStart); |
| 113 } | 113 } |
| 114 | 114 |
| 115 innerStyle->setPaddingLeft(Length(LayoutTheme::theme().popupInternalPaddingL
eft(style()), Fixed)); | 115 innerStyle.setPaddingLeft(Length(LayoutTheme::theme().popupInternalPaddingLe
ft(styleRef()), Fixed)); |
| 116 innerStyle->setPaddingRight(Length(LayoutTheme::theme().popupInternalPadding
Right(style()), Fixed)); | 116 innerStyle.setPaddingRight(Length(LayoutTheme::theme().popupInternalPaddingR
ight(styleRef()), Fixed)); |
| 117 innerStyle->setPaddingTop(Length(LayoutTheme::theme().popupInternalPaddingTo
p(style()), Fixed)); | 117 innerStyle.setPaddingTop(Length(LayoutTheme::theme().popupInternalPaddingTop
(styleRef()), Fixed)); |
| 118 innerStyle->setPaddingBottom(Length(LayoutTheme::theme().popupInternalPaddin
gBottom(style()), Fixed)); | 118 innerStyle.setPaddingBottom(Length(LayoutTheme::theme().popupInternalPadding
Bottom(styleRef()), Fixed)); |
| 119 | 119 |
| 120 if (m_optionStyle) { | 120 if (m_optionStyle) { |
| 121 if ((m_optionStyle->direction() != innerStyle->direction() || m_optionSt
yle->unicodeBidi() != innerStyle->unicodeBidi())) | 121 if ((m_optionStyle->direction() != innerStyle.direction() || m_optionSty
le->unicodeBidi() != innerStyle.unicodeBidi())) |
| 122 m_innerBlock->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidat
ion(); | 122 m_innerBlock->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidat
ion(); |
| 123 innerStyle->setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGH
T); | 123 innerStyle.setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGHT
); |
| 124 innerStyle->setDirection(m_optionStyle->direction()); | 124 innerStyle.setDirection(m_optionStyle->direction()); |
| 125 innerStyle->setUnicodeBidi(m_optionStyle->unicodeBidi()); | 125 innerStyle.setUnicodeBidi(m_optionStyle->unicodeBidi()); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 inline HTMLSelectElement* RenderMenuList::selectElement() const | 129 inline HTMLSelectElement* RenderMenuList::selectElement() const |
| 130 { | 130 { |
| 131 return toHTMLSelectElement(node()); | 131 return toHTMLSelectElement(node()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void RenderMenuList::addChild(RenderObject* newChild, RenderObject* beforeChild) | 134 void RenderMenuList::addChild(RenderObject* newChild, RenderObject* beforeChild) |
| 135 { | 135 { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 316 |
| 317 LayoutRect innerBox(additionalOffset + m_innerBlock->location() | 317 LayoutRect innerBox(additionalOffset + m_innerBlock->location() |
| 318 + LayoutSize(m_innerBlock->paddingLeft(), m_innerBlock->paddingTop()) | 318 + LayoutSize(m_innerBlock->paddingLeft(), m_innerBlock->paddingTop()) |
| 319 , m_innerBlock->contentSize()); | 319 , m_innerBlock->contentSize()); |
| 320 | 320 |
| 321 return intersection(outerBox, innerBox); | 321 return intersection(outerBox, innerBox); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void RenderMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth,
LayoutUnit& maxLogicalWidth) const | 324 void RenderMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth,
LayoutUnit& maxLogicalWidth) const |
| 325 { | 325 { |
| 326 maxLogicalWidth = std::max(m_optionsWidth, LayoutTheme::theme().minimumMenuL
istSize(style())) + m_innerBlock->paddingLeft() + m_innerBlock->paddingRight(); | 326 maxLogicalWidth = std::max(m_optionsWidth, LayoutTheme::theme().minimumMenuL
istSize(styleRef())) + m_innerBlock->paddingLeft() + m_innerBlock->paddingRight(
); |
| 327 if (!style()->width().isPercent()) | 327 if (!style()->width().isPercent()) |
| 328 minLogicalWidth = maxLogicalWidth; | 328 minLogicalWidth = maxLogicalWidth; |
| 329 } | 329 } |
| 330 | 330 |
| 331 void RenderMenuList::showPopup() | 331 void RenderMenuList::showPopup() |
| 332 { | 332 { |
| 333 if (m_popupIsVisible) | 333 if (m_popupIsVisible) |
| 334 return; | 334 return; |
| 335 | 335 |
| 336 if (document().frameHost()->chrome().hasOpenedPopup()) | 336 if (document().frameHost()->chrome().hasOpenedPopup()) |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 HTMLElement* element = listItems[listIndex]; | 576 HTMLElement* element = listItems[listIndex]; |
| 577 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select
ed(); | 577 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select
ed(); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void RenderMenuList::setTextFromItem(unsigned listIndex) | 580 void RenderMenuList::setTextFromItem(unsigned listIndex) |
| 581 { | 581 { |
| 582 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); | 582 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); |
| 583 } | 583 } |
| 584 | 584 |
| 585 } // namespace blink | 585 } // namespace blink |
| OLD | NEW |