| OLD | NEW |
| 1 /** | 1 /** |
| 2 * This file is part of the theme implementation for form controls in WebCore. | 2 * This file is part of the theme implementation for form controls in WebCore. |
| 3 * | 3 * |
| 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. | 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #include "public/platform/WebFallbackThemeEngine.h" | 60 #include "public/platform/WebFallbackThemeEngine.h" |
| 61 #include "public/platform/WebRect.h" | 61 #include "public/platform/WebRect.h" |
| 62 #include "wtf/text/StringBuilder.h" | 62 #include "wtf/text/StringBuilder.h" |
| 63 | 63 |
| 64 // The methods in this file are shared by all themes on every platform. | 64 // The methods in this file are shared by all themes on every platform. |
| 65 | 65 |
| 66 namespace blink { | 66 namespace blink { |
| 67 | 67 |
| 68 using namespace HTMLNames; | 68 using namespace HTMLNames; |
| 69 | 69 |
| 70 static WebFallbackThemeEngine::State getWebFallbackThemeState(const LayoutTheme*
theme, const RenderObject* o) | 70 static WebFallbackThemeEngine::State getWebFallbackThemeState(const LayoutTheme*
theme, const LayoutObject* o) |
| 71 { | 71 { |
| 72 if (!theme->isEnabled(o)) | 72 if (!theme->isEnabled(o)) |
| 73 return WebFallbackThemeEngine::StateDisabled; | 73 return WebFallbackThemeEngine::StateDisabled; |
| 74 if (theme->isPressed(o)) | 74 if (theme->isPressed(o)) |
| 75 return WebFallbackThemeEngine::StatePressed; | 75 return WebFallbackThemeEngine::StatePressed; |
| 76 if (theme->isHovered(o)) | 76 if (theme->isHovered(o)) |
| 77 return WebFallbackThemeEngine::StateHover; | 77 return WebFallbackThemeEngine::StateHover; |
| 78 | 78 |
| 79 return WebFallbackThemeEngine::StateNormal; | 79 return WebFallbackThemeEngine::StateNormal; |
| 80 } | 80 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return adjustSearchFieldCancelButtonStyle(style, e); | 222 return adjustSearchFieldCancelButtonStyle(style, e); |
| 223 case SearchFieldDecorationPart: | 223 case SearchFieldDecorationPart: |
| 224 return adjustSearchFieldDecorationStyle(style, e); | 224 return adjustSearchFieldDecorationStyle(style, e); |
| 225 case SearchFieldResultsDecorationPart: | 225 case SearchFieldResultsDecorationPart: |
| 226 return adjustSearchFieldResultsDecorationStyle(style, e); | 226 return adjustSearchFieldResultsDecorationStyle(style, e); |
| 227 default: | 227 default: |
| 228 break; | 228 break; |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool LayoutTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe
ct& r) | 232 bool LayoutTheme::paint(LayoutObject* o, const PaintInfo& paintInfo, const IntRe
ct& r) |
| 233 { | 233 { |
| 234 ControlPart part = o->style()->appearance(); | 234 ControlPart part = o->style()->appearance(); |
| 235 | 235 |
| 236 if (shouldUseFallbackTheme(o->style())) | 236 if (shouldUseFallbackTheme(o->style())) |
| 237 return paintUsingFallbackTheme(o, paintInfo, r); | 237 return paintUsingFallbackTheme(o, paintInfo, r); |
| 238 | 238 |
| 239 #if USE(NEW_THEME) | 239 #if USE(NEW_THEME) |
| 240 switch (part) { | 240 switch (part) { |
| 241 case CheckboxPart: | 241 case CheckboxPart: |
| 242 case RadioPart: | 242 case RadioPart: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 return paintSearchFieldDecoration(o, paintInfo, r); | 328 return paintSearchFieldDecoration(o, paintInfo, r); |
| 329 case SearchFieldResultsDecorationPart: | 329 case SearchFieldResultsDecorationPart: |
| 330 return paintSearchFieldResultsDecoration(o, paintInfo, r); | 330 return paintSearchFieldResultsDecoration(o, paintInfo, r); |
| 331 default: | 331 default: |
| 332 break; | 332 break; |
| 333 } | 333 } |
| 334 | 334 |
| 335 return true; // We don't support the appearance, so let the normal backgroun
d/border paint. | 335 return true; // We don't support the appearance, so let the normal backgroun
d/border paint. |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool LayoutTheme::paintBorderOnly(RenderObject* o, const PaintInfo& paintInfo, c
onst IntRect& r) | 338 bool LayoutTheme::paintBorderOnly(LayoutObject* o, const PaintInfo& paintInfo, c
onst IntRect& r) |
| 339 { | 339 { |
| 340 // Call the appropriate paint method based off the appearance value. | 340 // Call the appropriate paint method based off the appearance value. |
| 341 switch (o->style()->appearance()) { | 341 switch (o->style()->appearance()) { |
| 342 case TextFieldPart: | 342 case TextFieldPart: |
| 343 return paintTextField(o, paintInfo, r); | 343 return paintTextField(o, paintInfo, r); |
| 344 case TextAreaPart: | 344 case TextAreaPart: |
| 345 return paintTextArea(o, paintInfo, r); | 345 return paintTextArea(o, paintInfo, r); |
| 346 case MenulistButtonPart: | 346 case MenulistButtonPart: |
| 347 case SearchFieldPart: | 347 case SearchFieldPart: |
| 348 case ListboxPart: | 348 case ListboxPart: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 366 case SearchFieldCancelButtonPart: | 366 case SearchFieldCancelButtonPart: |
| 367 case SearchFieldDecorationPart: | 367 case SearchFieldDecorationPart: |
| 368 case SearchFieldResultsDecorationPart: | 368 case SearchFieldResultsDecorationPart: |
| 369 default: | 369 default: |
| 370 break; | 370 break; |
| 371 } | 371 } |
| 372 | 372 |
| 373 return false; | 373 return false; |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool LayoutTheme::paintDecorations(RenderObject* o, const PaintInfo& paintInfo,
const IntRect& r) | 376 bool LayoutTheme::paintDecorations(LayoutObject* o, const PaintInfo& paintInfo,
const IntRect& r) |
| 377 { | 377 { |
| 378 // Call the appropriate paint method based off the appearance value. | 378 // Call the appropriate paint method based off the appearance value. |
| 379 switch (o->style()->appearance()) { | 379 switch (o->style()->appearance()) { |
| 380 case MenulistButtonPart: | 380 case MenulistButtonPart: |
| 381 return paintMenuListButton(o, paintInfo, r); | 381 return paintMenuListButton(o, paintInfo, r); |
| 382 case TextFieldPart: | 382 case TextFieldPart: |
| 383 case TextAreaPart: | 383 case TextAreaPart: |
| 384 case CheckboxPart: | 384 case CheckboxPart: |
| 385 case RadioPart: | 385 case RadioPart: |
| 386 case PushButtonPart: | 386 case PushButtonPart: |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 Color LayoutTheme::platformInactiveListBoxSelectionBackgroundColor() const | 517 Color LayoutTheme::platformInactiveListBoxSelectionBackgroundColor() const |
| 518 { | 518 { |
| 519 return platformInactiveSelectionBackgroundColor(); | 519 return platformInactiveSelectionBackgroundColor(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 Color LayoutTheme::platformInactiveListBoxSelectionForegroundColor() const | 522 Color LayoutTheme::platformInactiveListBoxSelectionForegroundColor() const |
| 523 { | 523 { |
| 524 return platformInactiveSelectionForegroundColor(); | 524 return platformInactiveSelectionForegroundColor(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 int LayoutTheme::baselinePosition(const RenderObject* o) const | 527 int LayoutTheme::baselinePosition(const LayoutObject* o) const |
| 528 { | 528 { |
| 529 if (!o->isBox()) | 529 if (!o->isBox()) |
| 530 return 0; | 530 return 0; |
| 531 | 531 |
| 532 const RenderBox* box = toRenderBox(o); | 532 const RenderBox* box = toRenderBox(o); |
| 533 | 533 |
| 534 #if USE(NEW_THEME) | 534 #if USE(NEW_THEME) |
| 535 return box->size().height() + box->marginTop() + m_platformTheme->baselinePo
sitionAdjustment(o->style()->appearance()) * o->style()->effectiveZoom(); | 535 return box->size().height() + box->marginTop() + m_platformTheme->baselinePo
sitionAdjustment(o->style()->appearance()) * o->style()->effectiveZoom(); |
| 536 #else | 536 #else |
| 537 return box->size().height() + box->marginTop(); | 537 return box->size().height() + box->marginTop(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 case SliderHorizontalPart: | 585 case SliderHorizontalPart: |
| 586 case SliderVerticalPart: | 586 case SliderVerticalPart: |
| 587 return style->boxShadow(); | 587 return style->boxShadow(); |
| 588 | 588 |
| 589 default: | 589 default: |
| 590 return false; | 590 return false; |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 void LayoutTheme::adjustPaintInvalidationRect(const RenderObject* o, IntRect& r) | 594 void LayoutTheme::adjustPaintInvalidationRect(const LayoutObject* o, IntRect& r) |
| 595 { | 595 { |
| 596 #if USE(NEW_THEME) | 596 #if USE(NEW_THEME) |
| 597 m_platformTheme->inflateControlPaintRect(o->style()->appearance(), controlSt
atesForRenderer(o), r, o->style()->effectiveZoom()); | 597 m_platformTheme->inflateControlPaintRect(o->style()->appearance(), controlSt
atesForRenderer(o), r, o->style()->effectiveZoom()); |
| 598 #endif | 598 #endif |
| 599 } | 599 } |
| 600 | 600 |
| 601 bool LayoutTheme::shouldDrawDefaultFocusRing(RenderObject* renderer) const | 601 bool LayoutTheme::shouldDrawDefaultFocusRing(LayoutObject* renderer) const |
| 602 { | 602 { |
| 603 if (supportsFocusRing(renderer->style())) | 603 if (supportsFocusRing(renderer->style())) |
| 604 return false; | 604 return false; |
| 605 Node* node = renderer->node(); | 605 Node* node = renderer->node(); |
| 606 if (!node) | 606 if (!node) |
| 607 return true; | 607 return true; |
| 608 if (!renderer->style()->hasAppearance() && !node->isLink()) | 608 if (!renderer->style()->hasAppearance() && !node->isLink()) |
| 609 return true; | 609 return true; |
| 610 // We can't use LayoutTheme::isFocused because outline:auto might be | 610 // We can't use LayoutTheme::isFocused because outline:auto might be |
| 611 // specified to non-:focus rulesets. | 611 // specified to non-:focus rulesets. |
| 612 if (node->focused() && !node->shouldHaveFocusAppearance()) | 612 if (node->focused() && !node->shouldHaveFocusAppearance()) |
| 613 return false; | 613 return false; |
| 614 return true; | 614 return true; |
| 615 } | 615 } |
| 616 | 616 |
| 617 bool LayoutTheme::supportsFocusRing(const RenderStyle* style) const | 617 bool LayoutTheme::supportsFocusRing(const RenderStyle* style) const |
| 618 { | 618 { |
| 619 return (style->hasAppearance() && style->appearance() != TextFieldPart && st
yle->appearance() != TextAreaPart && style->appearance() != MenulistButtonPart &
& style->appearance() != ListboxPart); | 619 return (style->hasAppearance() && style->appearance() != TextFieldPart && st
yle->appearance() != TextAreaPart && style->appearance() != MenulistButtonPart &
& style->appearance() != ListboxPart); |
| 620 } | 620 } |
| 621 | 621 |
| 622 bool LayoutTheme::stateChanged(RenderObject* o, ControlState state) const | 622 bool LayoutTheme::stateChanged(LayoutObject* o, ControlState state) const |
| 623 { | 623 { |
| 624 // Default implementation assumes the controls don't respond to changes in :
hover state | 624 // Default implementation assumes the controls don't respond to changes in :
hover state |
| 625 if (state == HoverControlState && !supportsHover(o->style())) | 625 if (state == HoverControlState && !supportsHover(o->style())) |
| 626 return false; | 626 return false; |
| 627 | 627 |
| 628 // Assume pressed state is only responded to if the control is enabled. | 628 // Assume pressed state is only responded to if the control is enabled. |
| 629 if (state == PressedControlState && !isEnabled(o)) | 629 if (state == PressedControlState && !isEnabled(o)) |
| 630 return false; | 630 return false; |
| 631 | 631 |
| 632 o->setShouldDoFullPaintInvalidation(); | 632 o->setShouldDoFullPaintInvalidation(); |
| 633 return true; | 633 return true; |
| 634 } | 634 } |
| 635 | 635 |
| 636 ControlStates LayoutTheme::controlStatesForRenderer(const RenderObject* o) const | 636 ControlStates LayoutTheme::controlStatesForRenderer(const LayoutObject* o) const |
| 637 { | 637 { |
| 638 ControlStates result = 0; | 638 ControlStates result = 0; |
| 639 if (isHovered(o)) { | 639 if (isHovered(o)) { |
| 640 result |= HoverControlState; | 640 result |= HoverControlState; |
| 641 if (isSpinUpButtonPartHovered(o)) | 641 if (isSpinUpButtonPartHovered(o)) |
| 642 result |= SpinUpControlState; | 642 result |= SpinUpControlState; |
| 643 } | 643 } |
| 644 if (isPressed(o)) { | 644 if (isPressed(o)) { |
| 645 result |= PressedControlState; | 645 result |= PressedControlState; |
| 646 if (isSpinUpButtonPartPressed(o)) | 646 if (isSpinUpButtonPartPressed(o)) |
| 647 result |= SpinUpControlState; | 647 result |= SpinUpControlState; |
| 648 } | 648 } |
| 649 if (isFocused(o) && o->style()->outlineStyleIsAuto()) | 649 if (isFocused(o) && o->style()->outlineStyleIsAuto()) |
| 650 result |= FocusControlState; | 650 result |= FocusControlState; |
| 651 if (isEnabled(o)) | 651 if (isEnabled(o)) |
| 652 result |= EnabledControlState; | 652 result |= EnabledControlState; |
| 653 if (isChecked(o)) | 653 if (isChecked(o)) |
| 654 result |= CheckedControlState; | 654 result |= CheckedControlState; |
| 655 if (isReadOnlyControl(o)) | 655 if (isReadOnlyControl(o)) |
| 656 result |= ReadOnlyControlState; | 656 result |= ReadOnlyControlState; |
| 657 if (!isActive(o)) | 657 if (!isActive(o)) |
| 658 result |= WindowInactiveControlState; | 658 result |= WindowInactiveControlState; |
| 659 if (isIndeterminate(o)) | 659 if (isIndeterminate(o)) |
| 660 result |= IndeterminateControlState; | 660 result |= IndeterminateControlState; |
| 661 return result; | 661 return result; |
| 662 } | 662 } |
| 663 | 663 |
| 664 bool LayoutTheme::isActive(const RenderObject* o) const | 664 bool LayoutTheme::isActive(const LayoutObject* o) const |
| 665 { | 665 { |
| 666 Node* node = o->node(); | 666 Node* node = o->node(); |
| 667 if (!node) | 667 if (!node) |
| 668 return false; | 668 return false; |
| 669 | 669 |
| 670 Page* page = node->document().page(); | 670 Page* page = node->document().page(); |
| 671 if (!page) | 671 if (!page) |
| 672 return false; | 672 return false; |
| 673 | 673 |
| 674 return page->focusController().isActive(); | 674 return page->focusController().isActive(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 bool LayoutTheme::isChecked(const RenderObject* o) const | 677 bool LayoutTheme::isChecked(const LayoutObject* o) const |
| 678 { | 678 { |
| 679 if (!isHTMLInputElement(o->node())) | 679 if (!isHTMLInputElement(o->node())) |
| 680 return false; | 680 return false; |
| 681 return toHTMLInputElement(o->node())->shouldAppearChecked(); | 681 return toHTMLInputElement(o->node())->shouldAppearChecked(); |
| 682 } | 682 } |
| 683 | 683 |
| 684 bool LayoutTheme::isIndeterminate(const RenderObject* o) const | 684 bool LayoutTheme::isIndeterminate(const LayoutObject* o) const |
| 685 { | 685 { |
| 686 if (!isHTMLInputElement(o->node())) | 686 if (!isHTMLInputElement(o->node())) |
| 687 return false; | 687 return false; |
| 688 return toHTMLInputElement(o->node())->shouldAppearIndeterminate(); | 688 return toHTMLInputElement(o->node())->shouldAppearIndeterminate(); |
| 689 } | 689 } |
| 690 | 690 |
| 691 bool LayoutTheme::isEnabled(const RenderObject* o) const | 691 bool LayoutTheme::isEnabled(const LayoutObject* o) const |
| 692 { | 692 { |
| 693 Node* node = o->node(); | 693 Node* node = o->node(); |
| 694 if (!node || !node->isElementNode()) | 694 if (!node || !node->isElementNode()) |
| 695 return true; | 695 return true; |
| 696 return !toElement(node)->isDisabledFormControl(); | 696 return !toElement(node)->isDisabledFormControl(); |
| 697 } | 697 } |
| 698 | 698 |
| 699 bool LayoutTheme::isFocused(const RenderObject* o) const | 699 bool LayoutTheme::isFocused(const LayoutObject* o) const |
| 700 { | 700 { |
| 701 Node* node = o->node(); | 701 Node* node = o->node(); |
| 702 if (!node) | 702 if (!node) |
| 703 return false; | 703 return false; |
| 704 | 704 |
| 705 node = node->focusDelegate(); | 705 node = node->focusDelegate(); |
| 706 Document& document = node->document(); | 706 Document& document = node->document(); |
| 707 LocalFrame* frame = document.frame(); | 707 LocalFrame* frame = document.frame(); |
| 708 return node == document.focusedElement() && node->focused() && node->shouldH
aveFocusAppearance() && frame && frame->selection().isFocusedAndActive(); | 708 return node == document.focusedElement() && node->focused() && node->shouldH
aveFocusAppearance() && frame && frame->selection().isFocusedAndActive(); |
| 709 } | 709 } |
| 710 | 710 |
| 711 bool LayoutTheme::isPressed(const RenderObject* o) const | 711 bool LayoutTheme::isPressed(const LayoutObject* o) const |
| 712 { | 712 { |
| 713 if (!o->node()) | 713 if (!o->node()) |
| 714 return false; | 714 return false; |
| 715 return o->node()->active(); | 715 return o->node()->active(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 bool LayoutTheme::isSpinUpButtonPartPressed(const RenderObject* o) const | 718 bool LayoutTheme::isSpinUpButtonPartPressed(const LayoutObject* o) const |
| 719 { | 719 { |
| 720 Node* node = o->node(); | 720 Node* node = o->node(); |
| 721 if (!node || !node->active() || !node->isElementNode() | 721 if (!node || !node->active() || !node->isElementNode() |
| 722 || !toElement(node)->isSpinButtonElement()) | 722 || !toElement(node)->isSpinButtonElement()) |
| 723 return false; | 723 return false; |
| 724 SpinButtonElement* element = toSpinButtonElement(node); | 724 SpinButtonElement* element = toSpinButtonElement(node); |
| 725 return element->upDownState() == SpinButtonElement::Up; | 725 return element->upDownState() == SpinButtonElement::Up; |
| 726 } | 726 } |
| 727 | 727 |
| 728 bool LayoutTheme::isReadOnlyControl(const RenderObject* o) const | 728 bool LayoutTheme::isReadOnlyControl(const LayoutObject* o) const |
| 729 { | 729 { |
| 730 Node* node = o->node(); | 730 Node* node = o->node(); |
| 731 if (!node || !node->isElementNode() || !toElement(node)->isFormControlElemen
t()) | 731 if (!node || !node->isElementNode() || !toElement(node)->isFormControlElemen
t()) |
| 732 return false; | 732 return false; |
| 733 HTMLFormControlElement* element = toHTMLFormControlElement(node); | 733 HTMLFormControlElement* element = toHTMLFormControlElement(node); |
| 734 return element->isReadOnly(); | 734 return element->isReadOnly(); |
| 735 } | 735 } |
| 736 | 736 |
| 737 bool LayoutTheme::isHovered(const RenderObject* o) const | 737 bool LayoutTheme::isHovered(const LayoutObject* o) const |
| 738 { | 738 { |
| 739 Node* node = o->node(); | 739 Node* node = o->node(); |
| 740 if (!node) | 740 if (!node) |
| 741 return false; | 741 return false; |
| 742 if (!node->isElementNode() || !toElement(node)->isSpinButtonElement()) | 742 if (!node->isElementNode() || !toElement(node)->isSpinButtonElement()) |
| 743 return node->hovered(); | 743 return node->hovered(); |
| 744 SpinButtonElement* element = toSpinButtonElement(node); | 744 SpinButtonElement* element = toSpinButtonElement(node); |
| 745 return element->hovered() && element->upDownState() != SpinButtonElement::In
determinate; | 745 return element->hovered() && element->upDownState() != SpinButtonElement::In
determinate; |
| 746 } | 746 } |
| 747 | 747 |
| 748 bool LayoutTheme::isSpinUpButtonPartHovered(const RenderObject* o) const | 748 bool LayoutTheme::isSpinUpButtonPartHovered(const LayoutObject* o) const |
| 749 { | 749 { |
| 750 Node* node = o->node(); | 750 Node* node = o->node(); |
| 751 if (!node || !node->isElementNode() || !toElement(node)->isSpinButtonElement
()) | 751 if (!node || !node->isElementNode() || !toElement(node)->isSpinButtonElement
()) |
| 752 return false; | 752 return false; |
| 753 SpinButtonElement* element = toSpinButtonElement(node); | 753 SpinButtonElement* element = toSpinButtonElement(node); |
| 754 return element->upDownState() == SpinButtonElement::Up; | 754 return element->upDownState() == SpinButtonElement::Up; |
| 755 } | 755 } |
| 756 | 756 |
| 757 #if !USE(NEW_THEME) | 757 #if !USE(NEW_THEME) |
| 758 | 758 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 IntSize LayoutTheme::meterSizeForBounds(const RenderMeter*, const IntRect& bound
s) const | 802 IntSize LayoutTheme::meterSizeForBounds(const RenderMeter*, const IntRect& bound
s) const |
| 803 { | 803 { |
| 804 return bounds.size(); | 804 return bounds.size(); |
| 805 } | 805 } |
| 806 | 806 |
| 807 bool LayoutTheme::supportsMeter(ControlPart) const | 807 bool LayoutTheme::supportsMeter(ControlPart) const |
| 808 { | 808 { |
| 809 return false; | 809 return false; |
| 810 } | 810 } |
| 811 | 811 |
| 812 bool LayoutTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) | 812 bool LayoutTheme::paintMeter(LayoutObject*, const PaintInfo&, const IntRect&) |
| 813 { | 813 { |
| 814 return true; | 814 return true; |
| 815 } | 815 } |
| 816 | 816 |
| 817 void LayoutTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo,
const IntRect& rect) | 817 void LayoutTheme::paintSliderTicks(LayoutObject* o, const PaintInfo& paintInfo,
const IntRect& rect) |
| 818 { | 818 { |
| 819 Node* node = o->node(); | 819 Node* node = o->node(); |
| 820 if (!isHTMLInputElement(node)) | 820 if (!isHTMLInputElement(node)) |
| 821 return; | 821 return; |
| 822 | 822 |
| 823 HTMLInputElement* input = toHTMLInputElement(node); | 823 HTMLInputElement* input = toHTMLInputElement(node); |
| 824 if (input->type() != InputTypeNames::range) | 824 if (input->type() != InputTypeNames::range) |
| 825 return; | 825 return; |
| 826 | 826 |
| 827 HTMLDataListElement* dataList = input->dataList(); | 827 HTMLDataListElement* dataList = input->dataList(); |
| 828 if (!dataList) | 828 if (!dataList) |
| 829 return; | 829 return; |
| 830 | 830 |
| 831 double min = input->minimum(); | 831 double min = input->minimum(); |
| 832 double max = input->maximum(); | 832 double max = input->maximum(); |
| 833 ControlPart part = o->style()->appearance(); | 833 ControlPart part = o->style()->appearance(); |
| 834 // We don't support ticks on alternate sliders like MediaVolumeSliders. | 834 // We don't support ticks on alternate sliders like MediaVolumeSliders. |
| 835 if (part != SliderHorizontalPart && part != SliderVerticalPart) | 835 if (part != SliderHorizontalPart && part != SliderVerticalPart) |
| 836 return; | 836 return; |
| 837 bool isHorizontal = part == SliderHorizontalPart; | 837 bool isHorizontal = part == SliderHorizontalPart; |
| 838 | 838 |
| 839 IntSize thumbSize; | 839 IntSize thumbSize; |
| 840 RenderObject* thumbRenderer = input->userAgentShadowRoot()->getElementById(S
hadowElementNames::sliderThumb())->renderer(); | 840 LayoutObject* thumbRenderer = input->userAgentShadowRoot()->getElementById(S
hadowElementNames::sliderThumb())->renderer(); |
| 841 if (thumbRenderer) { | 841 if (thumbRenderer) { |
| 842 RenderStyle* thumbStyle = thumbRenderer->style(); | 842 RenderStyle* thumbStyle = thumbRenderer->style(); |
| 843 int thumbWidth = thumbStyle->width().intValue(); | 843 int thumbWidth = thumbStyle->width().intValue(); |
| 844 int thumbHeight = thumbStyle->height().intValue(); | 844 int thumbHeight = thumbStyle->height().intValue(); |
| 845 thumbSize.setWidth(isHorizontal ? thumbWidth : thumbHeight); | 845 thumbSize.setWidth(isHorizontal ? thumbWidth : thumbHeight); |
| 846 thumbSize.setHeight(isHorizontal ? thumbHeight : thumbWidth); | 846 thumbSize.setHeight(isHorizontal ? thumbHeight : thumbWidth); |
| 847 } | 847 } |
| 848 | 848 |
| 849 IntSize tickSize = sliderTickSize(); | 849 IntSize tickSize = sliderTickSize(); |
| 850 float zoomFactor = o->style()->effectiveZoom(); | 850 float zoomFactor = o->style()->effectiveZoom(); |
| 851 FloatRect tickRect; | 851 FloatRect tickRect; |
| 852 int tickRegionSideMargin = 0; | 852 int tickRegionSideMargin = 0; |
| 853 int tickRegionWidth = 0; | 853 int tickRegionWidth = 0; |
| 854 IntRect trackBounds; | 854 IntRect trackBounds; |
| 855 RenderObject* trackRenderer = input->userAgentShadowRoot()->getElementById(S
hadowElementNames::sliderTrack())->renderer(); | 855 LayoutObject* trackRenderer = input->userAgentShadowRoot()->getElementById(S
hadowElementNames::sliderTrack())->renderer(); |
| 856 // We can ignoring transforms because transform is handled by the graphics c
ontext. | 856 // We can ignoring transforms because transform is handled by the graphics c
ontext. |
| 857 if (trackRenderer) | 857 if (trackRenderer) |
| 858 trackBounds = trackRenderer->absoluteBoundingBoxRectIgnoringTransforms()
; | 858 trackBounds = trackRenderer->absoluteBoundingBoxRectIgnoringTransforms()
; |
| 859 IntRect sliderBounds = o->absoluteBoundingBoxRectIgnoringTransforms(); | 859 IntRect sliderBounds = o->absoluteBoundingBoxRectIgnoringTransforms(); |
| 860 | 860 |
| 861 // Make position relative to the transformed ancestor element. | 861 // Make position relative to the transformed ancestor element. |
| 862 trackBounds.setX(trackBounds.x() - sliderBounds.x() + rect.x()); | 862 trackBounds.setX(trackBounds.x() - sliderBounds.x() + rect.x()); |
| 863 trackBounds.setY(trackBounds.y() - sliderBounds.y() + rect.y()); | 863 trackBounds.setY(trackBounds.y() - sliderBounds.y() + rect.y()); |
| 864 | 864 |
| 865 if (isHorizontal) { | 865 if (isHorizontal) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 switch (part) { | 1150 switch (part) { |
| 1151 case CheckboxPart: | 1151 case CheckboxPart: |
| 1152 return adjustCheckboxStyleUsingFallbackTheme(style, e); | 1152 return adjustCheckboxStyleUsingFallbackTheme(style, e); |
| 1153 case RadioPart: | 1153 case RadioPart: |
| 1154 return adjustRadioStyleUsingFallbackTheme(style, e); | 1154 return adjustRadioStyleUsingFallbackTheme(style, e); |
| 1155 default: | 1155 default: |
| 1156 break; | 1156 break; |
| 1157 } | 1157 } |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 bool LayoutTheme::paintUsingFallbackTheme(RenderObject* o, const PaintInfo& i, c
onst IntRect& r) | 1160 bool LayoutTheme::paintUsingFallbackTheme(LayoutObject* o, const PaintInfo& i, c
onst IntRect& r) |
| 1161 { | 1161 { |
| 1162 ControlPart part = o->style()->appearance(); | 1162 ControlPart part = o->style()->appearance(); |
| 1163 switch (part) { | 1163 switch (part) { |
| 1164 case CheckboxPart: | 1164 case CheckboxPart: |
| 1165 return paintCheckboxUsingFallbackTheme(o, i, r); | 1165 return paintCheckboxUsingFallbackTheme(o, i, r); |
| 1166 case RadioPart: | 1166 case RadioPart: |
| 1167 return paintRadioUsingFallbackTheme(o, i, r); | 1167 return paintRadioUsingFallbackTheme(o, i, r); |
| 1168 default: | 1168 default: |
| 1169 break; | 1169 break; |
| 1170 } | 1170 } |
| 1171 return true; | 1171 return true; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 // static | 1174 // static |
| 1175 void LayoutTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size) | 1175 void LayoutTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size) |
| 1176 { | 1176 { |
| 1177 if (style->width().isIntrinsicOrAuto()) | 1177 if (style->width().isIntrinsicOrAuto()) |
| 1178 style->setWidth(Length(size.width(), Fixed)); | 1178 style->setWidth(Length(size.width(), Fixed)); |
| 1179 if (style->height().isAuto()) | 1179 if (style->height().isAuto()) |
| 1180 style->setHeight(Length(size.height(), Fixed)); | 1180 style->setHeight(Length(size.height(), Fixed)); |
| 1181 } | 1181 } |
| 1182 | 1182 |
| 1183 bool LayoutTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn
fo& i, const IntRect& r) | 1183 bool LayoutTheme::paintCheckboxUsingFallbackTheme(LayoutObject* o, const PaintIn
fo& i, const IntRect& r) |
| 1184 { | 1184 { |
| 1185 WebFallbackThemeEngine::ExtraParams extraParams; | 1185 WebFallbackThemeEngine::ExtraParams extraParams; |
| 1186 WebCanvas* canvas = i.context->canvas(); | 1186 WebCanvas* canvas = i.context->canvas(); |
| 1187 extraParams.button.checked = isChecked(o); | 1187 extraParams.button.checked = isChecked(o); |
| 1188 extraParams.button.indeterminate = isIndeterminate(o); | 1188 extraParams.button.indeterminate = isIndeterminate(o); |
| 1189 | 1189 |
| 1190 float zoomLevel = o->style()->effectiveZoom(); | 1190 float zoomLevel = o->style()->effectiveZoom(); |
| 1191 GraphicsContextStateSaver stateSaver(*i.context); | 1191 GraphicsContextStateSaver stateSaver(*i.context); |
| 1192 IntRect unzoomedRect = r; | 1192 IntRect unzoomedRect = r; |
| 1193 if (zoomLevel != 1) { | 1193 if (zoomLevel != 1) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1215 setSizeIfAuto(style, size); | 1215 setSizeIfAuto(style, size); |
| 1216 | 1216 |
| 1217 // padding - not honored by WinIE, needs to be removed. | 1217 // padding - not honored by WinIE, needs to be removed. |
| 1218 style->resetPadding(); | 1218 style->resetPadding(); |
| 1219 | 1219 |
| 1220 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) | 1220 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) |
| 1221 // for now, we will not honor it. | 1221 // for now, we will not honor it. |
| 1222 style->resetBorder(); | 1222 style->resetBorder(); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 bool LayoutTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo&
i, const IntRect& r) | 1225 bool LayoutTheme::paintRadioUsingFallbackTheme(LayoutObject* o, const PaintInfo&
i, const IntRect& r) |
| 1226 { | 1226 { |
| 1227 WebFallbackThemeEngine::ExtraParams extraParams; | 1227 WebFallbackThemeEngine::ExtraParams extraParams; |
| 1228 WebCanvas* canvas = i.context->canvas(); | 1228 WebCanvas* canvas = i.context->canvas(); |
| 1229 extraParams.button.checked = isChecked(o); | 1229 extraParams.button.checked = isChecked(o); |
| 1230 extraParams.button.indeterminate = isIndeterminate(o); | 1230 extraParams.button.indeterminate = isIndeterminate(o); |
| 1231 | 1231 |
| 1232 float zoomLevel = o->style()->effectiveZoom(); | 1232 float zoomLevel = o->style()->effectiveZoom(); |
| 1233 GraphicsContextStateSaver stateSaver(*i.context); | 1233 GraphicsContextStateSaver stateSaver(*i.context); |
| 1234 IntRect unzoomedRect = r; | 1234 IntRect unzoomedRect = r; |
| 1235 if (zoomLevel != 1) { | 1235 if (zoomLevel != 1) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1258 | 1258 |
| 1259 // padding - not honored by WinIE, needs to be removed. | 1259 // padding - not honored by WinIE, needs to be removed. |
| 1260 style->resetPadding(); | 1260 style->resetPadding(); |
| 1261 | 1261 |
| 1262 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) | 1262 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) |
| 1263 // for now, we will not honor it. | 1263 // for now, we will not honor it. |
| 1264 style->resetBorder(); | 1264 style->resetBorder(); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 } // namespace blink | 1267 } // namespace blink |
| OLD | NEW |