Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: Source/core/rendering/RenderTheme.cpp

Issue 197283025: Use new is*Element() helper functions more in rendering code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 704
705 Page* page = node->document().page(); 705 Page* page = node->document().page();
706 if (!page) 706 if (!page)
707 return false; 707 return false;
708 708
709 return page->focusController().isActive(); 709 return page->focusController().isActive();
710 } 710 }
711 711
712 bool RenderTheme::isChecked(const RenderObject* o) const 712 bool RenderTheme::isChecked(const RenderObject* o) const
713 { 713 {
714 if (!o->node() || !o->node()->hasTagName(inputTag)) 714 if (!isHTMLInputElement(o->node()))
715 return false; 715 return false;
716 return toHTMLInputElement(o->node())->shouldAppearChecked(); 716 return toHTMLInputElement(o->node())->shouldAppearChecked();
717 } 717 }
718 718
719 bool RenderTheme::isIndeterminate(const RenderObject* o) const 719 bool RenderTheme::isIndeterminate(const RenderObject* o) const
720 { 720 {
721 if (!o->node() || !o->node()->hasTagName(inputTag)) 721 if (!isHTMLInputElement(o->node()))
722 return false; 722 return false;
723 return toHTMLInputElement(o->node())->shouldAppearIndeterminate(); 723 return toHTMLInputElement(o->node())->shouldAppearIndeterminate();
724 } 724 }
725 725
726 bool RenderTheme::isEnabled(const RenderObject* o) const 726 bool RenderTheme::isEnabled(const RenderObject* o) const
727 { 727 {
728 Node* node = o->node(); 728 Node* node = o->node();
729 if (!node || !node->isElementNode()) 729 if (!node || !node->isElementNode())
730 return true; 730 return true;
731 return !toElement(node)->isDisabledFormControl(); 731 return !toElement(node)->isDisabledFormControl();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 } 857 }
858 858
859 bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) 859 bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&)
860 { 860 {
861 return true; 861 return true;
862 } 862 }
863 863
864 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) 864 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect)
865 { 865 {
866 Node* node = o->node(); 866 Node* node = o->node();
867 if (!node || !node->hasTagName(inputTag)) 867 if (!isHTMLInputElement(node))
868 return; 868 return;
869 869
870 HTMLInputElement* input = toHTMLInputElement(node); 870 HTMLInputElement* input = toHTMLInputElement(node);
871 HTMLDataListElement* dataList = input->dataList(); 871 HTMLDataListElement* dataList = input->dataList();
872 if (!dataList) 872 if (!dataList)
873 return; 873 return;
874 874
875 double min = input->minimum(); 875 double min = input->minimum();
876 double max = input->maximum(); 876 double max = input->maximum();
877 ControlPart part = o->style()->appearance(); 877 ControlPart part = o->style()->appearance();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 tickRect.setWidth(floor(tickSize.height() * zoomFactor)); 916 tickRect.setWidth(floor(tickSize.height() * zoomFactor));
917 tickRect.setHeight(floor(tickSize.width() * zoomFactor)); 917 tickRect.setHeight(floor(tickSize.width() * zoomFactor));
918 tickRect.setX(floor(rect.x() + rect.width() / 2.0 + sliderTickOffsetFrom TrackCenter() * zoomFactor)); 918 tickRect.setX(floor(rect.x() + rect.width() / 2.0 + sliderTickOffsetFrom TrackCenter() * zoomFactor));
919 tickRegionSideMargin = trackBounds.y() + (thumbSize.width() - tickSize.w idth() * zoomFactor) / 2.0; 919 tickRegionSideMargin = trackBounds.y() + (thumbSize.width() - tickSize.w idth() * zoomFactor) / 2.0;
920 tickRegionWidth = trackBounds.height() - thumbSize.width(); 920 tickRegionWidth = trackBounds.height() - thumbSize.width();
921 } 921 }
922 RefPtr<HTMLCollection> options = dataList->options(); 922 RefPtr<HTMLCollection> options = dataList->options();
923 GraphicsContextStateSaver stateSaver(*paintInfo.context); 923 GraphicsContextStateSaver stateSaver(*paintInfo.context);
924 paintInfo.context->setFillColor(o->resolveColor(CSSPropertyColor)); 924 paintInfo.context->setFillColor(o->resolveColor(CSSPropertyColor));
925 for (unsigned i = 0; Element* element = options->item(i); i++) { 925 for (unsigned i = 0; Element* element = options->item(i); i++) {
926 ASSERT(element->hasTagName(optionTag)); 926 ASSERT(isHTMLOptionElement(*element));
927 HTMLOptionElement* optionElement = toHTMLOptionElement(element); 927 HTMLOptionElement& optionElement = toHTMLOptionElement(*element);
928 String value = optionElement->value(); 928 String value = optionElement.value();
929 if (!input->isValidValue(value)) 929 if (!input->isValidValue(value))
930 continue; 930 continue;
931 double parsedValue = parseToDoubleForNumberType(input->sanitizeValue(val ue)); 931 double parsedValue = parseToDoubleForNumberType(input->sanitizeValue(val ue));
932 double tickFraction = (parsedValue - min) / (max - min); 932 double tickFraction = (parsedValue - min) / (max - min);
933 double tickRatio = isHorizontal && o->style()->isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction; 933 double tickRatio = isHorizontal && o->style()->isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction;
934 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic kRatio); 934 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic kRatio);
935 if (isHorizontal) 935 if (isHorizontal)
936 tickRect.setX(tickPosition); 936 tickRect.setX(tickPosition);
937 else 937 else
938 tickRect.setY(tickPosition); 938 tickRect.setY(tickPosition);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 1248
1249 // padding - not honored by WinIE, needs to be removed. 1249 // padding - not honored by WinIE, needs to be removed.
1250 style->resetPadding(); 1250 style->resetPadding();
1251 1251
1252 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) 1252 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)
1253 // for now, we will not honor it. 1253 // for now, we will not honor it.
1254 style->resetBorder(); 1254 style->resetBorder();
1255 } 1255 }
1256 1256
1257 } // namespace WebCore 1257 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTextControlSingleLine.cpp ('k') | Source/core/rendering/RenderTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698