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

Side by Side Diff: Source/core/rendering/RenderThemeChromiumMac.mm

Issue 16532002: Clear button for date/time inputs should be zoomable (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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
« no previous file with comments | « Source/core/css/html.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 730
731 // Reset line height 731 // Reset line height
732 style->setLineHeight(RenderStyle::initialLineHeight()); 732 style->setLineHeight(RenderStyle::initialLineHeight());
733 733
734 if (style->setFontDescription(fontDescription)) 734 if (style->setFontDescription(fontDescription))
735 style->font().update(0); 735 style->font().update(0);
736 } 736 }
737 737
738 NSControlSize RenderThemeChromiumMac::controlSizeForSystemFont(RenderStyle* styl e) const 738 NSControlSize RenderThemeChromiumMac::controlSizeForSystemFont(RenderStyle* styl e) const
739 { 739 {
740 int fontSize = style->fontSize(); 740 float fontSize = style->fontSize();
741 float zoomLevel = style->effectiveZoom();
742 if (zoomLevel != 1.0)
tkent 2013/06/13 21:54:23 1.0 should be 1.
keishi 2013/06/14 05:17:01 Done.
743 fontSize /= zoomLevel;
741 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) 744 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize])
742 return NSRegularControlSize; 745 return NSRegularControlSize;
743 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) 746 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize])
744 return NSSmallControlSize; 747 return NSSmallControlSize;
745 return NSMiniControlSize; 748 return NSMiniControlSize;
746 } 749 }
747 750
748 bool RenderThemeChromiumMac::paintTextField(RenderObject* o, const PaintInfo& pa intInfo, const IntRect& r) 751 bool RenderThemeChromiumMac::paintTextField(RenderObject* o, const PaintInfo& pa intInfo, const IntRect& r)
749 { 752 {
750 LocalCurrentGraphicsContext localContext(paintInfo.context); 753 LocalCurrentGraphicsContext localContext(paintInfo.context);
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 updateEnabledState(search, o); 1565 updateEnabledState(search, o);
1563 updateFocusedState(search, o); 1566 updateFocusedState(search, o);
1564 } 1567 }
1565 1568
1566 const IntSize* RenderThemeChromiumMac::searchFieldSizes() const 1569 const IntSize* RenderThemeChromiumMac::searchFieldSizes() const
1567 { 1570 {
1568 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17) }; 1571 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17) };
1569 return sizes; 1572 return sizes;
1570 } 1573 }
1571 1574
1575 static const int* searchFieldHorizontalPaddings()
1576 {
1577 static const int sizes[3] = { 3, 2, 1 };
1578 return sizes;
1579 }
1580
1572 void RenderThemeChromiumMac::setSearchFieldSize(RenderStyle* style) const 1581 void RenderThemeChromiumMac::setSearchFieldSize(RenderStyle* style) const
1573 { 1582 {
1574 // If the width and height are both specified, then we have nothing to do. 1583 // If the width and height are both specified, then we have nothing to do.
1575 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) 1584 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
1576 return; 1585 return;
1577 1586
1578 // Use the font size to determine the intrinsic width of the control. 1587 // Use the font size to determine the intrinsic width of the control.
1579 setSizeFromFont(style, searchFieldSizes()); 1588 setSizeFromFont(style, searchFieldSizes());
1580 } 1589 }
1581 1590
1582 void RenderThemeChromiumMac::adjustSearchFieldStyle(RenderStyle* style, Element* ) const 1591 void RenderThemeChromiumMac::adjustSearchFieldStyle(RenderStyle* style, Element* ) const
1583 { 1592 {
1584 // Override border. 1593 // Override border.
1585 style->resetBorder(); 1594 style->resetBorder();
1586 const short borderWidth = 2 * style->effectiveZoom(); 1595 const short borderWidth = 2 * style->effectiveZoom();
1587 style->setBorderLeftWidth(borderWidth); 1596 style->setBorderLeftWidth(borderWidth);
1588 style->setBorderLeftStyle(INSET); 1597 style->setBorderLeftStyle(INSET);
1589 style->setBorderRightWidth(borderWidth); 1598 style->setBorderRightWidth(borderWidth);
1590 style->setBorderRightStyle(INSET); 1599 style->setBorderRightStyle(INSET);
1591 style->setBorderBottomWidth(borderWidth); 1600 style->setBorderBottomWidth(borderWidth);
1592 style->setBorderBottomStyle(INSET); 1601 style->setBorderBottomStyle(INSET);
1593 style->setBorderTopWidth(borderWidth); 1602 style->setBorderTopWidth(borderWidth);
1594 style->setBorderTopStyle(INSET); 1603 style->setBorderTopStyle(INSET);
1595 1604
1596 // Override height. 1605 // Override height.
1597 style->setHeight(Length(Auto)); 1606 style->setHeight(Length(Auto));
1598 setSearchFieldSize(style); 1607 setSearchFieldSize(style);
1599 1608
1609 NSControlSize controlSize = controlSizeForFont(style);
1610
1600 // Override padding size to match AppKit text positioning. 1611 // Override padding size to match AppKit text positioning.
1601 const int padding = 1 * style->effectiveZoom(); 1612 const int verticalPadding = 1 * style->effectiveZoom();
1602 style->setPaddingLeft(Length(padding, Fixed)); 1613 const int horizontalPadding = searchFieldHorizontalPaddings()[controlSize] * style->effectiveZoom();
1603 style->setPaddingRight(Length(padding, Fixed)); 1614 style->setPaddingLeft(Length(horizontalPadding, Fixed));
1604 style->setPaddingTop(Length(padding, Fixed)); 1615 style->setPaddingRight(Length(horizontalPadding, Fixed));
1605 style->setPaddingBottom(Length(padding, Fixed)); 1616 style->setPaddingTop(Length(verticalPadding, Fixed));
1617 style->setPaddingBottom(Length(verticalPadding, Fixed));
1606 1618
1607 NSControlSize controlSize = controlSizeForFont(style);
1608 setFontFromControlSize(style, controlSize); 1619 setFontFromControlSize(style, controlSize);
1609 1620
1610 style->setBoxShadow(nullptr); 1621 style->setBoxShadow(nullptr);
1611 } 1622 }
1612 1623
1613 bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) 1624 bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
1614 { 1625 {
1615 Element* input = o->node()->shadowHost(); 1626 Element* input = o->node()->shadowHost();
1616 if (!input) 1627 if (!input)
1617 input = toElement(o->node()); 1628 input = toElement(o->node());
1618 1629
1619 if (!input->renderer()->isBox()) 1630 if (!input->renderer()->isBox())
1620 return false; 1631 return false;
1621 1632
1622 LocalCurrentGraphicsContext localContext(paintInfo.context);
1623
1624 NSSearchFieldCell* search = this->search();
1625 setSearchCellState(input->renderer(), r);
1626 [search setControlSize:cancelButtonControlSizeForFont(o->style())];
1627
1628 if (!input->isDisabledFormControl() && (input->isTextFormControl() && !toHTM LTextFormControlElement(input)->isReadOnly())) {
1629 updateActiveState([search cancelButtonCell], o);
1630 updatePressedState([search cancelButtonCell], o);
1631 }
1632 else if ([[search cancelButtonCell] isHighlighted])
1633 [[search cancelButtonCell] setHighlighted:NO];
1634
1635 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1633 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1636 1634
1637 float zoomLevel = o->style()->effectiveZoom(); 1635 float zoomLevel = o->style()->effectiveZoom();
1638 FloatRect unzoomedRect(r); 1636 FloatRect unzoomedRect(r);
1639 if (zoomLevel != 1.0f) { 1637 if (zoomLevel != 1.0f) {
1640 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 1638 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
1641 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 1639 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
1642 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); 1640 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
1643 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); 1641 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
1644 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 1642 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
1645 } 1643 }
1646 1644
1647 [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor (o)]; 1645 Color fillColor(200, 200, 200);
1648 [[search cancelButtonCell] setControlView:nil]; 1646
1647 if (isPressed(o)) {
1648 Color tintColor(0, 0, 0, 32);
1649 fillColor = fillColor.blend(tintColor);
1650 }
1651
1652 float centerX = unzoomedRect.x() + unzoomedRect.width() / 2.0;
tkent 2013/06/13 21:54:23 2.0 should be 2.
keishi 2013/06/14 05:17:01 Done.
1653 float centerY = unzoomedRect.y() + unzoomedRect.height() / 2.0;
tkent 2013/06/13 21:54:23 ditto.
keishi 2013/06/14 05:17:01 Done.
1654 // The line width is 3px on a regular sized, high DPI NSCancelButtonCell
1655 // (which is 28px wide).
1656 float lineWidth = unzoomedRect.width() * 3 / 28;
1657 // The line length is 16.5px on a regular sized, high DPI NSCancelButtonCell .
1658 float lineLength = unzoomedRect.width() * 16 / 28;
tkent 2013/06/13 21:54:23 Why isn't it 16.5?
keishi 2013/06/14 05:17:01 16.5px looked best in my vector illustration progr
1659
1660 Path xPath;
1661 FloatSize lineRectRadius(lineWidth / 2, lineWidth / 2);
1662 xPath.addRoundedRect(FloatRect(-lineLength / 2, -lineWidth / 2, lineLength, lineWidth),
1663 lineRectRadius, lineRectRadius, lineRectRadius, lineRectRadius);
1664 xPath.addRoundedRect(FloatRect(-lineWidth / 2, -lineLength / 2, lineWidth, l ineLength),
1665 lineRectRadius, lineRectRadius, lineRectRadius, lineRectRadius);
1666
1667 paintInfo.context->translate(centerX, centerY);
1668 paintInfo.context->rotate(deg2rad(45.0));
1669 paintInfo.context->clipOut(xPath);
1670 paintInfo.context->rotate(deg2rad(-45.0));
1671 paintInfo.context->translate(-centerX, -centerY);
1672
1673 paintInfo.context->setFillColor(fillColor);
1674 paintInfo.context->fillEllipse(unzoomedRect);
1675
1649 return false; 1676 return false;
1650 } 1677 }
1651 1678
1652 const IntSize* RenderThemeChromiumMac::cancelButtonSizes() const 1679 const IntSize* RenderThemeChromiumMac::cancelButtonSizes() const
1653 { 1680 {
1654 static const IntSize sizes[3] = { IntSize(16, 14), IntSize(13, 11), IntSize( 13, 9) }; 1681 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(11, 11), IntSize( 9, 9) };
1655 return sizes; 1682 return sizes;
1656 } 1683 }
1657 1684
1658 void RenderThemeChromiumMac::adjustSearchFieldCancelButtonStyle(RenderStyle* sty le, Element*) const 1685 void RenderThemeChromiumMac::adjustSearchFieldCancelButtonStyle(RenderStyle* sty le, Element*) const
1659 { 1686 {
1660 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); 1687 IntSize size = sizeForSystemFont(style, cancelButtonSizes());
1661 style->setWidth(Length(size.width(), Fixed)); 1688 style->setWidth(Length(size.width(), Fixed));
1662 style->setHeight(Length(size.height(), Fixed)); 1689 style->setHeight(Length(size.height(), Fixed));
1663 style->setBoxShadow(nullptr); 1690 style->setBoxShadow(nullptr);
1664 } 1691 }
1665 1692
1666 const IntSize* RenderThemeChromiumMac::resultsButtonSizes() const 1693 const IntSize* RenderThemeChromiumMac::resultsButtonSizes() const
1667 { 1694 {
1668 static const IntSize sizes[3] = { IntSize(19, 13), IntSize(17, 11), IntSize( 17, 9) }; 1695 static const IntSize sizes[3] = { IntSize(16, 13), IntSize(16, 11), IntSize( 16, 9) };
1669 return sizes; 1696 return sizes;
1670 } 1697 }
1671 1698
1672 const int emptyResultsOffset = 9; 1699 const int emptyResultsOffset = 9;
1673 void RenderThemeChromiumMac::adjustSearchFieldDecorationStyle(RenderStyle* style , Element*) const 1700 void RenderThemeChromiumMac::adjustSearchFieldDecorationStyle(RenderStyle* style , Element*) const
1674 { 1701 {
1675 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); 1702 IntSize size = sizeForSystemFont(style, resultsButtonSizes());
1676 style->setWidth(Length(size.width() - emptyResultsOffset, Fixed)); 1703 style->setWidth(Length(size.width() - emptyResultsOffset, Fixed));
1677 style->setHeight(Length(size.height(), Fixed)); 1704 style->setHeight(Length(size.height(), Fixed));
1678 style->setBoxShadow(nullptr); 1705 style->setBoxShadow(nullptr);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 1992
1966 bool RenderThemeChromiumMac::shouldUseFallbackTheme(RenderStyle* style) const 1993 bool RenderThemeChromiumMac::shouldUseFallbackTheme(RenderStyle* style) const
1967 { 1994 {
1968 ControlPart part = style->appearance(); 1995 ControlPart part = style->appearance();
1969 if (part == CheckboxPart || part == RadioPart) 1996 if (part == CheckboxPart || part == RadioPart)
1970 return style->effectiveZoom() != 1; 1997 return style->effectiveZoom() != 1;
1971 return false; 1998 return false;
1972 } 1999 }
1973 2000
1974 } // namespace WebCore 2001 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/html.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698