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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // Try to retrieve the style of an option element we know exists (index
0). | 468 // Try to retrieve the style of an option element we know exists (index
0). |
469 listIndex = 0; | 469 listIndex = 0; |
470 } | 470 } |
471 HTMLElement* element = listItems[listIndex]; | 471 HTMLElement* element = listItems[listIndex]; |
472 | 472 |
473 Color itemBackgroundColor; | 473 Color itemBackgroundColor; |
474 bool itemHasCustomBackgroundColor; | 474 bool itemHasCustomBackgroundColor; |
475 getItemBackgroundColor(listIndex, itemBackgroundColor, itemHasCustomBackgrou
ndColor); | 475 getItemBackgroundColor(listIndex, itemBackgroundColor, itemHasCustomBackgrou
ndColor); |
476 | 476 |
477 RenderStyle* style = element->renderStyle() ? element->renderStyle() : eleme
nt->computedStyle(); | 477 RenderStyle* style = element->renderStyle() ? element->renderStyle() : eleme
nt->computedStyle(); |
478 return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor)
, itemBackgroundColor, style->font(), style->visibility() == VISIBLE, | 478 return style ? PopupMenuStyle(resolveColor(style, CSSPropertyColor), itemBac
kgroundColor, style->font(), style->visibility() == VISIBLE, |
479 style->display() == NONE, style->textIndent(), style->direction(), isOve
rride(style->unicodeBidi()), | 479 style->display() == NONE, style->textIndent(), style->direction(), isOve
rride(style->unicodeBidi()), |
480 itemHasCustomBackgroundColor ? PopupMenuStyle::CustomBackgroundColor : P
opupMenuStyle::DefaultBackgroundColor) : menuStyle(); | 480 itemHasCustomBackgroundColor ? PopupMenuStyle::CustomBackgroundColor : P
opupMenuStyle::DefaultBackgroundColor) : menuStyle(); |
481 } | 481 } |
482 | 482 |
483 void RenderMenuList::getItemBackgroundColor(unsigned listIndex, Color& itemBackg
roundColor, bool& itemHasCustomBackgroundColor) const | 483 void RenderMenuList::getItemBackgroundColor(unsigned listIndex, Color& itemBackg
roundColor, bool& itemHasCustomBackgroundColor) const |
484 { | 484 { |
485 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 485 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
486 if (listIndex >= listItems.size()) { | 486 if (listIndex >= listItems.size()) { |
487 itemBackgroundColor = style()->visitedDependentColor(CSSPropertyBackgrou
ndColor); | 487 itemBackgroundColor = resolveColor(CSSPropertyBackgroundColor); |
488 itemHasCustomBackgroundColor = false; | 488 itemHasCustomBackgroundColor = false; |
489 return; | 489 return; |
490 } | 490 } |
491 HTMLElement* element = listItems[listIndex]; | 491 HTMLElement* element = listItems[listIndex]; |
492 | 492 |
493 Color backgroundColor; | 493 Color backgroundColor; |
494 if (element->renderStyle()) | 494 if (element->renderStyle()) |
495 backgroundColor = element->renderStyle()->visitedDependentColor(CSSPrope
rtyBackgroundColor); | 495 backgroundColor = resolveColor(element->renderStyle(), CSSPropertyBackgr
oundColor); |
496 itemHasCustomBackgroundColor = backgroundColor.isValid() && backgroundColor.
alpha(); | 496 itemHasCustomBackgroundColor = backgroundColor.isValid() && backgroundColor.
alpha(); |
497 // If the item has an opaque background color, return that. | 497 // If the item has an opaque background color, return that. |
498 if (!backgroundColor.hasAlpha()) { | 498 if (!backgroundColor.hasAlpha()) { |
499 itemBackgroundColor = backgroundColor; | 499 itemBackgroundColor = backgroundColor; |
500 return; | 500 return; |
501 } | 501 } |
502 | 502 |
503 // Otherwise, the item's background is overlayed on top of the menu backgrou
nd. | 503 // Otherwise, the item's background is overlayed on top of the menu backgrou
nd. |
504 backgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor)
.blend(backgroundColor); | 504 backgroundColor = resolveColor(CSSPropertyBackgroundColor).blend(backgroundC
olor); |
505 if (!backgroundColor.hasAlpha()) { | 505 if (!backgroundColor.hasAlpha()) { |
506 itemBackgroundColor = backgroundColor; | 506 itemBackgroundColor = backgroundColor; |
507 return; | 507 return; |
508 } | 508 } |
509 | 509 |
510 // If the menu background is not opaque, then add an opaque white background
behind. | 510 // If the menu background is not opaque, then add an opaque white background
behind. |
511 itemBackgroundColor = Color(Color::white).blend(backgroundColor); | 511 itemBackgroundColor = Color(Color::white).blend(backgroundColor); |
512 } | 512 } |
513 | 513 |
514 PopupMenuStyle RenderMenuList::menuStyle() const | 514 PopupMenuStyle RenderMenuList::menuStyle() const |
515 { | 515 { |
516 RenderStyle* s = m_innerBlock ? m_innerBlock->style() : style(); | 516 const RenderObject* o = m_innerBlock ? m_innerBlock : this; |
517 return PopupMenuStyle(s->visitedDependentColor(CSSPropertyColor), s->visited
DependentColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBL
E, | 517 const RenderStyle* s = o->style(); |
| 518 return PopupMenuStyle(o->resolveColor(CSSPropertyColor), o->resolveColor(CSS
PropertyBackgroundColor), s->font(), s->visibility() == VISIBLE, |
518 s->display() == NONE, s->textIndent(), style()->direction(), isOverride(
style()->unicodeBidi())); | 519 s->display() == NONE, s->textIndent(), style()->direction(), isOverride(
style()->unicodeBidi())); |
519 } | 520 } |
520 | 521 |
521 HostWindow* RenderMenuList::hostWindow() const | 522 HostWindow* RenderMenuList::hostWindow() const |
522 { | 523 { |
523 return document()->view()->hostWindow(); | 524 return document()->view()->hostWindow(); |
524 } | 525 } |
525 | 526 |
526 PassRefPtr<Scrollbar> RenderMenuList::createScrollbar(ScrollableArea* scrollable
Area, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) | 527 PassRefPtr<Scrollbar> RenderMenuList::createScrollbar(ScrollableArea* scrollable
Area, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) |
527 { | 528 { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 { | 607 { |
607 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); | 608 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); |
608 } | 609 } |
609 | 610 |
610 FontSelector* RenderMenuList::fontSelector() const | 611 FontSelector* RenderMenuList::fontSelector() const |
611 { | 612 { |
612 return document()->styleResolver()->fontSelector(); | 613 return document()->styleResolver()->fontSelector(); |
613 } | 614 } |
614 | 615 |
615 } | 616 } |
OLD | NEW |