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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 contentWidth(), itemHeight()); | 282 contentWidth(), itemHeight()); |
283 } | 283 } |
284 | 284 |
285 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) | 285 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) |
286 { | 286 { |
287 if (style()->visibility() != VISIBLE) | 287 if (style()->visibility() != VISIBLE) |
288 return; | 288 return; |
289 | 289 |
290 int listItemsSize = numItems(); | 290 int listItemsSize = numItems(); |
291 | 291 |
292 if (paintInfo.phase == PaintPhaseForeground) { | 292 if (paintInfo.getPhase() == PaintPhaseForeground) { |
293 int index = m_indexOffset; | 293 int index = m_indexOffset; |
294 while (index < listItemsSize && index <= m_indexOffset + numVisibleItems
()) { | 294 while (index < listItemsSize && index <= m_indexOffset + numVisibleItems
()) { |
295 paintItemForeground(paintInfo, paintOffset, index); | 295 paintItemForeground(paintInfo, paintOffset, index); |
296 index++; | 296 index++; |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 // Paint the children. | 300 // Paint the children. |
301 RenderBlock::paintObject(paintInfo, paintOffset); | 301 RenderBlock::paintObject(paintInfo, paintOffset); |
302 | 302 |
303 switch (paintInfo.phase) { | 303 switch (paintInfo.getPhase()) { |
304 // Depending on whether we have overlay scrollbars they | 304 // Depending on whether we have overlay scrollbars they |
305 // get rendered in the foreground or background phases | 305 // get rendered in the foreground or background phases |
306 case PaintPhaseForeground: | 306 case PaintPhaseForeground: |
307 if (m_vBar->isOverlayScrollbar()) | 307 if (m_vBar->isOverlayScrollbar()) |
308 paintScrollbar(paintInfo, paintOffset); | 308 paintScrollbar(paintInfo, paintOffset); |
309 break; | 309 break; |
310 case PaintPhaseBlockBackground: | 310 case PaintPhaseBlockBackground: |
311 if (!m_vBar->isOverlayScrollbar()) | 311 if (!m_vBar->isOverlayScrollbar()) |
312 paintScrollbar(paintInfo, paintOffset); | 312 paintScrollbar(paintInfo, paintOffset); |
313 break; | 313 break; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 } | 352 } |
353 | 353 |
354 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) | 354 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) |
355 { | 355 { |
356 if (m_vBar) { | 356 if (m_vBar) { |
357 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + width() - bor
derRight() - m_vBar->width(), | 357 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + width() - bor
derRight() - m_vBar->width(), |
358 paintOffset.y() + borderTop(), | 358 paintOffset.y() + borderTop(), |
359 m_vBar->width(), | 359 m_vBar->width(), |
360 height() - (borderTop() + borderBottom())); | 360 height() - (borderTop() + borderBottom())); |
361 m_vBar->setFrameRect(scrollRect); | 361 m_vBar->setFrameRect(scrollRect); |
362 m_vBar->paint(paintInfo.context, paintInfo.rect); | 362 m_vBar->paint(paintInfo.getContext(), paintInfo.getRect()); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle
, Font itemFont, LayoutRect itemBoudingBox) | 366 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle
, Font itemFont, LayoutRect itemBoudingBox) |
367 { | 367 { |
368 ETextAlign actualAlignment = itemStyle->textAlign(); | 368 ETextAlign actualAlignment = itemStyle->textAlign(); |
369 // FIXME: Firefox doesn't respect JUSTIFY. Should we? | 369 // FIXME: Firefox doesn't respect JUSTIFY. Should we? |
370 // FIXME: Handle TAEND here | 370 // FIXME: Handle TAEND here |
371 if (actualAlignment == TASTART || actualAlignment == JUSTIFY) | 371 if (actualAlignment == TASTART || actualAlignment == JUSTIFY) |
372 actualAlignment = itemStyle->isLeftToRightDirection() ? LEFT : RIGHT; | 372 actualAlignment = itemStyle->isLeftToRightDirection() ? LEFT : RIGHT; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 409 |
410 Color textColor = element->renderStyle() ? resolveColor(element->renderStyle
(), CSSPropertyColor) : resolveColor(CSSPropertyColor); | 410 Color textColor = element->renderStyle() ? resolveColor(element->renderStyle
(), CSSPropertyColor) : resolveColor(CSSPropertyColor); |
411 if (isOptionElement && toHTMLOptionElement(element)->selected()) { | 411 if (isOptionElement && toHTMLOptionElement(element)->selected()) { |
412 if (frame()->selection()->isFocusedAndActive() && document()->focusedEle
ment() == node()) | 412 if (frame()->selection()->isFocusedAndActive() && document()->focusedEle
ment() == 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.getContext()->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 (isHTMLOptGroupElement(element)) { | 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.getContext()->drawBidiText(itemFont, textRunPaintInfo, roundedIntP
oint(r.location())); |
437 } | 437 } |
438 | 438 |
439 void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint&
paintOffset, int listIndex) | 439 void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint&
paintOffset, int listIndex) |
440 { | 440 { |
441 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 441 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
442 HTMLElement* element = listItems[listIndex]; | 442 HTMLElement* element = listItems[listIndex]; |
443 | 443 |
444 Color backColor; | 444 Color backColor; |
445 if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected
()) { | 445 if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected
()) { |
446 if (frame()->selection()->isFocusedAndActive() && document()->focusedEle
ment() == node()) | 446 if (frame()->selection()->isFocusedAndActive() && document()->focusedEle
ment() == node()) |
447 backColor = theme()->activeListBoxSelectionBackgroundColor(); | 447 backColor = theme()->activeListBoxSelectionBackgroundColor(); |
448 else | 448 else |
449 backColor = theme()->inactiveListBoxSelectionBackgroundColor(); | 449 backColor = theme()->inactiveListBoxSelectionBackgroundColor(); |
450 } else { | 450 } else { |
451 backColor = element->renderStyle() ? resolveColor(element->renderStyle()
, CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor); | 451 backColor = element->renderStyle() ? resolveColor(element->renderStyle()
, CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor); |
452 } | 452 } |
453 | 453 |
454 // Draw the background for this list box item | 454 // Draw the background for this list box item |
455 if (!element->renderStyle() || element->renderStyle()->visibility() != HIDDE
N) { | 455 if (!element->renderStyle() || element->renderStyle()->visibility() != HIDDE
N) { |
456 LayoutRect itemRect = itemBoundingBoxRect(paintOffset, listIndex); | 456 LayoutRect itemRect = itemBoundingBoxRect(paintOffset, listIndex); |
457 itemRect.intersect(controlClipRect(paintOffset)); | 457 itemRect.intersect(controlClipRect(paintOffset)); |
458 paintInfo.context->fillRect(pixelSnappedIntRect(itemRect), backColor); | 458 paintInfo.getContext()->fillRect(pixelSnappedIntRect(itemRect), backColo
r); |
459 } | 459 } |
460 } | 460 } |
461 | 461 |
462 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout
Point& locationInContainer, const LayoutPoint& accumulatedOffset) | 462 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout
Point& locationInContainer, const LayoutPoint& accumulatedOffset) |
463 { | 463 { |
464 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) | 464 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) |
465 return false; | 465 return false; |
466 | 466 |
467 LayoutRect vertRect(accumulatedOffset.x() + width() - borderRight() - m_vBar
->width(), | 467 LayoutRect vertRect(accumulatedOffset.x() + width() - borderRight() - m_vBar
->width(), |
468 accumulatedOffset.y() + borderTop(), | 468 accumulatedOffset.y() + borderTop(), |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 889 |
890 if (m_vBar) | 890 if (m_vBar) |
891 m_vBar->styleChanged(); | 891 m_vBar->styleChanged(); |
892 | 892 |
893 // Force an update since we know the scrollbars have changed things. | 893 // Force an update since we know the scrollbars have changed things. |
894 if (document()->hasAnnotatedRegions()) | 894 if (document()->hasAnnotatedRegions()) |
895 document()->setAnnotatedRegionsDirty(true); | 895 document()->setAnnotatedRegionsDirty(true); |
896 } | 896 } |
897 | 897 |
898 } // namespace WebCore | 898 } // namespace WebCore |
OLD | NEW |