| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "platform/geometry/IntSize.h" | 46 #include "platform/geometry/IntSize.h" |
| 47 #include "platform/text/PlatformLocale.h" | 47 #include "platform/text/PlatformLocale.h" |
| 48 #include <math.h> | 48 #include <math.h> |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 using namespace HTMLNames; | 52 using namespace HTMLNames; |
| 53 | 53 |
| 54 RenderMenuList::RenderMenuList(Element* element) | 54 RenderMenuList::RenderMenuList(Element* element) |
| 55 : RenderFlexibleBox(element) | 55 : RenderFlexibleBox(element) |
| 56 , m_buttonText(0) | 56 , m_buttonText(nullptr) |
| 57 , m_innerBlock(0) | 57 , m_innerBlock(nullptr) |
| 58 , m_optionsChanged(true) | 58 , m_optionsChanged(true) |
| 59 , m_optionsWidth(0) | 59 , m_optionsWidth(0) |
| 60 , m_lastActiveIndex(-1) | 60 , m_lastActiveIndex(-1) |
| 61 , m_popupIsVisible(false) | 61 , m_popupIsVisible(false) |
| 62 { | 62 { |
| 63 ASSERT(isHTMLSelectElement(element)); | 63 ASSERT(isHTMLSelectElement(element)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 RenderMenuList::~RenderMenuList() | 66 RenderMenuList::~RenderMenuList() |
| 67 { | 67 { |
| 68 if (m_popup) | 68 if (m_popup) |
| 69 m_popup->disconnectClient(); | 69 m_popup->disconnectClient(); |
| 70 m_popup = nullptr; | 70 m_popup = nullptr; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void RenderMenuList::trace(Visitor* visitor) |
| 74 { |
| 75 visitor->trace(m_buttonText); |
| 76 visitor->trace(m_innerBlock); |
| 77 RenderFlexibleBox::trace(visitor); |
| 78 } |
| 79 |
| 73 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no in
sertion point | 80 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no in
sertion point |
| 74 // to prevent children from rendering. | 81 // to prevent children from rendering. |
| 75 bool RenderMenuList::isChildAllowed(RenderObject* object, RenderStyle*) const | 82 bool RenderMenuList::isChildAllowed(RenderObject* object, RenderStyle*) const |
| 76 { | 83 { |
| 77 return object->isAnonymous() && !object->isRenderFullScreen(); | 84 return object->isAnonymous() && !object->isRenderFullScreen(); |
| 78 } | 85 } |
| 79 | 86 |
| 80 void RenderMenuList::createInnerBlock() | 87 void RenderMenuList::createInnerBlock() |
| 81 { | 88 { |
| 82 if (m_innerBlock) { | 89 if (m_innerBlock) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 ASSERT(m_innerBlock == firstChild()); | 139 ASSERT(m_innerBlock == firstChild()); |
| 133 | 140 |
| 134 if (AXObjectCache* cache = document().existingAXObjectCache()) | 141 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 135 cache->childrenChanged(this); | 142 cache->childrenChanged(this); |
| 136 } | 143 } |
| 137 | 144 |
| 138 void RenderMenuList::removeChild(RenderObject* oldChild) | 145 void RenderMenuList::removeChild(RenderObject* oldChild) |
| 139 { | 146 { |
| 140 if (oldChild == m_innerBlock || !m_innerBlock) { | 147 if (oldChild == m_innerBlock || !m_innerBlock) { |
| 141 RenderFlexibleBox::removeChild(oldChild); | 148 RenderFlexibleBox::removeChild(oldChild); |
| 142 m_innerBlock = 0; | 149 m_innerBlock = nullptr; |
| 143 } else | 150 } else |
| 144 m_innerBlock->removeChild(oldChild); | 151 m_innerBlock->removeChild(oldChild); |
| 145 } | 152 } |
| 146 | 153 |
| 147 void RenderMenuList::styleDidChange(StyleDifference diff, const RenderStyle* old
Style) | 154 void RenderMenuList::styleDidChange(StyleDifference diff, const RenderStyle* old
Style) |
| 148 { | 155 { |
| 149 RenderBlock::styleDidChange(diff, oldStyle); | 156 RenderBlock::styleDidChange(diff, oldStyle); |
| 150 | 157 |
| 151 if (m_buttonText) | 158 if (m_buttonText) |
| 152 m_buttonText->setStyle(style()); | 159 m_buttonText->setStyle(style()); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 itemBackgroundColor = backgroundColor; | 540 itemBackgroundColor = backgroundColor; |
| 534 return; | 541 return; |
| 535 } | 542 } |
| 536 | 543 |
| 537 // If the menu background is not opaque, then add an opaque white background
behind. | 544 // If the menu background is not opaque, then add an opaque white background
behind. |
| 538 itemBackgroundColor = Color(Color::white).blend(backgroundColor); | 545 itemBackgroundColor = Color(Color::white).blend(backgroundColor); |
| 539 } | 546 } |
| 540 | 547 |
| 541 PopupMenuStyle RenderMenuList::menuStyle() const | 548 PopupMenuStyle RenderMenuList::menuStyle() const |
| 542 { | 549 { |
| 543 const RenderObject* o = m_innerBlock ? m_innerBlock : this; | 550 const RenderObject* o = m_innerBlock ? m_innerBlock.get() : this; |
| 544 const RenderStyle* s = o->style(); | 551 const RenderStyle* s = o->style(); |
| 545 return PopupMenuStyle(o->resolveColor(CSSPropertyColor), o->resolveColor(CSS
PropertyBackgroundColor), s->font(), s->visibility() == VISIBLE, | 552 return PopupMenuStyle(o->resolveColor(CSSPropertyColor), o->resolveColor(CSS
PropertyBackgroundColor), s->font(), s->visibility() == VISIBLE, |
| 546 s->display() == NONE, s->textIndent(), style()->direction(), isOverride(
style()->unicodeBidi())); | 553 s->display() == NONE, s->textIndent(), style()->direction(), isOverride(
style()->unicodeBidi())); |
| 547 } | 554 } |
| 548 | 555 |
| 549 LayoutUnit RenderMenuList::clientPaddingLeft() const | 556 LayoutUnit RenderMenuList::clientPaddingLeft() const |
| 550 { | 557 { |
| 551 return paddingLeft() + m_innerBlock->paddingLeft(); | 558 return paddingLeft() + m_innerBlock->paddingLeft(); |
| 552 } | 559 } |
| 553 | 560 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 HTMLElement* element = listItems[listIndex]; | 610 HTMLElement* element = listItems[listIndex]; |
| 604 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select
ed(); | 611 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select
ed(); |
| 605 } | 612 } |
| 606 | 613 |
| 607 void RenderMenuList::setTextFromItem(unsigned listIndex) | 614 void RenderMenuList::setTextFromItem(unsigned listIndex) |
| 608 { | 615 { |
| 609 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); | 616 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); |
| 610 } | 617 } |
| 611 | 618 |
| 612 } | 619 } |
| OLD | NEW |