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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 if (m_optionsChanged) { | 115 if (m_optionsChanged) { |
116 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 116 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
117 int size = numItems(); | 117 int size = numItems(); |
118 | 118 |
119 float width = 0; | 119 float width = 0; |
120 for (int i = 0; i < size; ++i) { | 120 for (int i = 0; i < size; ++i) { |
121 HTMLElement* element = listItems[i]; | 121 HTMLElement* element = listItems[i]; |
122 String text; | 122 String text; |
123 Font itemFont = style()->font(); | 123 Font itemFont = style()->font(); |
124 if (element->hasTagName(optionTag)) | 124 if (element->hasTagName(optionTag)) { |
125 text = toHTMLOptionElement(element)->textIndentedToRespectGroupL
abel(); | 125 text = toHTMLOptionElement(element)->textIndentedToRespectGroupL
abel(); |
126 else if (element->hasTagName(optgroupTag)) { | 126 } else if (isHTMLOptGroupElement(element)) { |
127 text = static_cast<const HTMLOptGroupElement*>(element)->groupLa
belText(); | 127 text = toHTMLOptGroupElement(element)->groupLabelText(); |
128 FontDescription d = itemFont.fontDescription(); | 128 FontDescription d = itemFont.fontDescription(); |
129 d.setWeight(d.bolderWeight()); | 129 d.setWeight(d.bolderWeight()); |
130 itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacin
g()); | 130 itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacin
g()); |
131 itemFont.update(document()->styleResolver()->fontSelector()); | 131 itemFont.update(document()->styleResolver()->fontSelector()); |
132 } | 132 } |
133 | 133 |
134 if (!text.isEmpty()) { | 134 if (!text.isEmpty()) { |
135 applyTextTransform(style(), text, ' '); | 135 applyTextTransform(style(), text, ' '); |
136 // FIXME: Why is this always LTR? Can't text direction affect th
e width? | 136 // FIXME: Why is this always LTR? Can't text direction affect th
e width? |
137 TextRun textRun = constructTextRun(this, itemFont, text, style()
, TextRun::AllowTrailingExpansion); | 137 TextRun textRun = constructTextRun(this, itemFont, text, style()
, TextRun::AllowTrailingExpansion); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 if (!itemStyle) | 396 if (!itemStyle) |
397 itemStyle = style(); | 397 itemStyle = style(); |
398 | 398 |
399 if (itemStyle->visibility() == HIDDEN) | 399 if (itemStyle->visibility() == HIDDEN) |
400 return; | 400 return; |
401 | 401 |
402 String itemText; | 402 String itemText; |
403 bool isOptionElement = element->hasTagName(optionTag); | 403 bool isOptionElement = element->hasTagName(optionTag); |
404 if (isOptionElement) | 404 if (isOptionElement) |
405 itemText = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel
(); | 405 itemText = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel
(); |
406 else if (element->hasTagName(optgroupTag)) | 406 else if (isHTMLOptGroupElement(element)) |
407 itemText = static_cast<const HTMLOptGroupElement*>(element)->groupLabelT
ext(); | 407 itemText = toHTMLOptGroupElement(element)->groupLabelText(); |
408 applyTextTransform(style(), itemText, ' '); | 408 applyTextTransform(style(), itemText, ' '); |
409 | 409 |
410 Color textColor = element->renderStyle() ? element->renderStyle()->visitedDe
pendentColor(CSSPropertyColor) : style()->visitedDependentColor(CSSPropertyColor
); | 410 Color textColor = element->renderStyle() ? element->renderStyle()->visitedDe
pendentColor(CSSPropertyColor) : style()->visitedDependentColor(CSSPropertyColor
); |
411 if (isOptionElement && toHTMLOptionElement(element)->selected()) { | 411 if (isOptionElement && toHTMLOptionElement(element)->selected()) { |
412 if (frame()->selection()->isFocusedAndActive() && document()->focusedNod
e() == node()) | 412 if (frame()->selection()->isFocusedAndActive() && document()->focusedNod
e() == node()) |
413 textColor = theme()->activeListBoxSelectionForegroundColor(); | 413 textColor = theme()->activeListBoxSelectionForegroundColor(); |
414 // Honor the foreground color for disabled items | 414 // Honor the foreground color for disabled items |
415 else if (!element->isDisabledFormControl() && !select->isDisabledFormCon
trol()) | 415 else if (!element->isDisabledFormControl() && !select->isDisabledFormCon
trol()) |
416 textColor = theme()->inactiveListBoxSelectionForegroundColor(); | 416 textColor = theme()->inactiveListBoxSelectionForegroundColor(); |
417 } | 417 } |
418 | 418 |
419 paintInfo.context->setFillColor(textColor); | 419 paintInfo.context->setFillColor(textColor); |
420 | 420 |
421 TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->
direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding); | 421 TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->
direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding); |
422 Font itemFont = style()->font(); | 422 Font itemFont = style()->font(); |
423 LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex); | 423 LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex); |
424 r.move(itemOffsetForAlignment(textRun, itemStyle, itemFont, r)); | 424 r.move(itemOffsetForAlignment(textRun, itemStyle, itemFont, r)); |
425 | 425 |
426 if (element->hasTagName(optgroupTag)) { | 426 if (isHTMLOptGroupElement(element)) { |
427 FontDescription d = itemFont.fontDescription(); | 427 FontDescription d = itemFont.fontDescription(); |
428 d.setWeight(d.bolderWeight()); | 428 d.setWeight(d.bolderWeight()); |
429 itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); | 429 itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); |
430 itemFont.update(document()->styleResolver()->fontSelector()); | 430 itemFont.update(document()->styleResolver()->fontSelector()); |
431 } | 431 } |
432 | 432 |
433 // Draw the item text | 433 // Draw the item text |
434 TextRunPaintInfo textRunPaintInfo(textRun); | 434 TextRunPaintInfo textRunPaintInfo(textRun); |
435 textRunPaintInfo.bounds = r; | 435 textRunPaintInfo.bounds = r; |
436 paintInfo.context->drawBidiText(itemFont, textRunPaintInfo, roundedIntPoint(
r.location())); | 436 paintInfo.context->drawBidiText(itemFont, textRunPaintInfo, roundedIntPoint(
r.location())); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 888 |
889 if (m_vBar) | 889 if (m_vBar) |
890 m_vBar->styleChanged(); | 890 m_vBar->styleChanged(); |
891 | 891 |
892 // Force an update since we know the scrollbars have changed things. | 892 // Force an update since we know the scrollbars have changed things. |
893 if (document()->hasAnnotatedRegions()) | 893 if (document()->hasAnnotatedRegions()) |
894 document()->setAnnotatedRegionsDirty(true); | 894 document()->setAnnotatedRegionsDirty(true); |
895 } | 895 } |
896 | 896 |
897 } // namespace WebCore | 897 } // namespace WebCore |
OLD | NEW |