OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 void RenderListBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) | 336 void RenderListBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) |
337 { | 337 { |
338 if (!isSpatialNavigationEnabled(frame())) | 338 if (!isSpatialNavigationEnabled(frame())) |
339 return RenderBlockFlow::addFocusRingRects(rects, additionalOffset, paint Container); | 339 return RenderBlockFlow::addFocusRingRects(rects, additionalOffset, paint Container); |
340 | 340 |
341 HTMLSelectElement* select = selectElement(); | 341 HTMLSelectElement* select = selectElement(); |
342 | 342 |
343 // Focus the previewed item. | |
tkent
2014/03/04 01:09:01
How does it look like? We need a rendering test.
| |
344 if (select->suggestedIndex() >= 0) { | |
345 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffset, s elect->suggestedIndex()))); | |
346 return; | |
347 } | |
348 | |
343 // Focus the last selected item. | 349 // Focus the last selected item. |
344 int selectedItem = select->activeSelectionEndListIndex(); | 350 int selectedItem = select->activeSelectionEndListIndex(); |
345 if (selectedItem >= 0) { | 351 if (selectedItem >= 0) { |
346 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffset, s electedItem))); | 352 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffset, s electedItem))); |
347 return; | 353 return; |
348 } | 354 } |
349 | 355 |
350 // No selected items, find the first non-disabled item. | 356 // No selected items, find the first non-disabled item. |
351 int size = numItems(); | 357 int size = numItems(); |
352 const Vector<HTMLElement*>& listItems = select->listItems(); | 358 const Vector<HTMLElement*>& listItems = select->listItems(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 | 425 |
420 String itemText; | 426 String itemText; |
421 bool isOptionElement = element->hasTagName(optionTag); | 427 bool isOptionElement = element->hasTagName(optionTag); |
422 if (isOptionElement) | 428 if (isOptionElement) |
423 itemText = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel (); | 429 itemText = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel (); |
424 else if (element->hasTagName(optgroupTag)) | 430 else if (element->hasTagName(optgroupTag)) |
425 itemText = toHTMLOptGroupElement(element)->groupLabelText(); | 431 itemText = toHTMLOptGroupElement(element)->groupLabelText(); |
426 applyTextTransform(style(), itemText, ' '); | 432 applyTextTransform(style(), itemText, ' '); |
427 | 433 |
428 Color textColor = element->renderStyle() ? resolveColor(element->renderStyle (), CSSPropertyColor) : resolveColor(CSSPropertyColor); | 434 Color textColor = element->renderStyle() ? resolveColor(element->renderStyle (), CSSPropertyColor) : resolveColor(CSSPropertyColor); |
429 if (isOptionElement && toHTMLOptionElement(element)->selected()) { | 435 if (isOptionElement && ((toHTMLOptionElement(element)->selected() && select- >suggestedIndex() < 0) || listIndex == select->suggestedIndex())) { |
430 if (frame()->selection().isFocusedAndActive() && document().focusedEleme nt() == node()) | 436 if (frame()->selection().isFocusedAndActive() && document().focusedEleme nt() == node()) |
431 textColor = RenderTheme::theme().activeListBoxSelectionForegroundCol or(); | 437 textColor = RenderTheme::theme().activeListBoxSelectionForegroundCol or(); |
432 // Honor the foreground color for disabled items | 438 // Honor the foreground color for disabled items |
433 else if (!element->isDisabledFormControl() && !select->isDisabledFormCon trol()) | 439 else if (!element->isDisabledFormControl() && !select->isDisabledFormCon trol()) |
434 textColor = RenderTheme::theme().inactiveListBoxSelectionForegroundC olor(); | 440 textColor = RenderTheme::theme().inactiveListBoxSelectionForegroundC olor(); |
435 } | 441 } |
436 | 442 |
437 paintInfo.context->setFillColor(textColor); | 443 paintInfo.context->setFillColor(textColor); |
438 | 444 |
439 TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, itemStyle-> direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding); | 445 TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, itemStyle-> direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding); |
(...skipping 13 matching lines...) Expand all Loading... | |
453 textRunPaintInfo.bounds = r; | 459 textRunPaintInfo.bounds = r; |
454 paintInfo.context->drawBidiText(itemFont, textRunPaintInfo, roundedIntPoint( r.location())); | 460 paintInfo.context->drawBidiText(itemFont, textRunPaintInfo, roundedIntPoint( r.location())); |
455 } | 461 } |
456 | 462 |
457 void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex) | 463 void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex) |
458 { | 464 { |
459 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 465 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
460 HTMLElement* element = listItems[listIndex]; | 466 HTMLElement* element = listItems[listIndex]; |
461 | 467 |
462 Color backColor; | 468 Color backColor; |
463 if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected ()) { | 469 if (element->hasTagName(optionTag) && ((toHTMLOptionElement(element)->select ed() && selectElement()->suggestedIndex() < 0) || listIndex == selectElement()-> suggestedIndex())) { |
464 if (frame()->selection().isFocusedAndActive() && document().focusedEleme nt() == node()) | 470 if (frame()->selection().isFocusedAndActive() && document().focusedEleme nt() == node()) |
465 backColor = RenderTheme::theme().activeListBoxSelectionBackgroundCol or(); | 471 backColor = RenderTheme::theme().activeListBoxSelectionBackgroundCol or(); |
466 else | 472 else |
467 backColor = RenderTheme::theme().inactiveListBoxSelectionBackgroundC olor(); | 473 backColor = RenderTheme::theme().inactiveListBoxSelectionBackgroundC olor(); |
468 } else { | 474 } else { |
469 backColor = element->renderStyle() ? resolveColor(element->renderStyle() , CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor); | 475 backColor = element->renderStyle() ? resolveColor(element->renderStyle() , CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor); |
470 } | 476 } |
471 | 477 |
472 // Draw the background for this list box item | 478 // Draw the background for this list box item |
473 if (!element->renderStyle() || element->renderStyle()->visibility() != HIDDE N) { | 479 if (!element->renderStyle() || element->renderStyle()->visibility() != HIDDE N) { |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 | 957 |
952 if (m_vBar) | 958 if (m_vBar) |
953 m_vBar->styleChanged(); | 959 m_vBar->styleChanged(); |
954 | 960 |
955 // Force an update since we know the scrollbars have changed things. | 961 // Force an update since we know the scrollbars have changed things. |
956 if (document().hasAnnotatedRegions()) | 962 if (document().hasAnnotatedRegions()) |
957 document().setAnnotatedRegionsDirty(true); | 963 document().setAnnotatedRegionsDirty(true); |
958 } | 964 } |
959 | 965 |
960 } // namespace WebCore | 966 } // namespace WebCore |
OLD | NEW |