Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 NSControlSize RenderThemeChromiumMac::controlSizeForFont(RenderStyle* style) con st | 653 NSControlSize RenderThemeChromiumMac::controlSizeForFont(RenderStyle* style) con st |
| 654 { | 654 { |
| 655 int fontSize = style->fontSize(); | 655 int fontSize = style->fontSize(); |
| 656 if (fontSize >= 16) | 656 if (fontSize >= 16) |
| 657 return NSRegularControlSize; | 657 return NSRegularControlSize; |
| 658 if (fontSize >= 11) | 658 if (fontSize >= 11) |
| 659 return NSSmallControlSize; | 659 return NSSmallControlSize; |
| 660 return NSMiniControlSize; | 660 return NSMiniControlSize; |
| 661 } | 661 } |
| 662 | 662 |
| 663 // We don't use controlSizeForFont() for cancel buttons because it needs to fit | |
| 664 // into the search field. The font size will already be modified by | |
| 665 // setFontFromControlSize() called on the search field. | |
| 666 NSControlSize RenderThemeChromiumMac::cancelButtonControlSizeForFont(RenderStyle * style) const | |
|
tkent
2013/05/27 22:44:50
We don't need to make this a member function of Re
keishi
2013/05/28 03:21:57
Done.
| |
| 667 { | |
| 668 int fontSize = style->fontSize(); | |
| 669 if (fontSize >= 13) | |
| 670 return NSRegularControlSize; | |
| 671 if (fontSize >= 11) | |
| 672 return NSSmallControlSize; | |
| 673 return NSMiniControlSize; | |
| 674 } | |
| 675 | |
| 663 void RenderThemeChromiumMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize, float zoomLevel) | 676 void RenderThemeChromiumMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize, float zoomLevel) |
| 664 { | 677 { |
| 665 NSControlSize size; | 678 NSControlSize size; |
| 666 if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomLevel) && | 679 if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomLevel) && |
| 667 minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height( ) * zoomLevel)) | 680 minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height( ) * zoomLevel)) |
| 668 size = NSRegularControlSize; | 681 size = NSRegularControlSize; |
| 669 else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width () * zoomLevel) && | 682 else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width () * zoomLevel) && |
| 670 minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].heig ht() * zoomLevel)) | 683 minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].heig ht() * zoomLevel)) |
| 671 size = NSSmallControlSize; | 684 size = NSSmallControlSize; |
| 672 else | 685 else |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1502 | 1515 |
| 1503 [sliderThumbCell drawInteriorWithFrame:unzoomedRect inView:documentViewFor(o )]; | 1516 [sliderThumbCell drawInteriorWithFrame:unzoomedRect inView:documentViewFor(o )]; |
| 1504 [sliderThumbCell setControlView:nil]; | 1517 [sliderThumbCell setControlView:nil]; |
| 1505 | 1518 |
| 1506 return false; | 1519 return false; |
| 1507 } | 1520 } |
| 1508 | 1521 |
| 1509 bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) | 1522 bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) |
| 1510 { | 1523 { |
| 1511 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1524 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1525 | |
| 1512 NSSearchFieldCell* search = this->search(); | 1526 NSSearchFieldCell* search = this->search(); |
| 1513 | |
| 1514 setSearchCellState(o, r); | 1527 setSearchCellState(o, r); |
| 1528 [search setControlSize:controlSizeForFont(o->style())]; | |
| 1515 | 1529 |
| 1516 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1530 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 1517 | 1531 |
| 1518 float zoomLevel = o->style()->effectiveZoom(); | 1532 float zoomLevel = o->style()->effectiveZoom(); |
| 1519 | 1533 |
| 1520 IntRect unzoomedRect = r; | 1534 IntRect unzoomedRect = r; |
| 1521 | 1535 |
| 1522 if (zoomLevel != 1.0f) { | 1536 if (zoomLevel != 1.0f) { |
| 1523 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1537 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1524 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1538 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1535 [search setControlView:nil]; | 1549 [search setControlView:nil]; |
| 1536 [search resetSearchButtonCell]; | 1550 [search resetSearchButtonCell]; |
| 1537 | 1551 |
| 1538 return false; | 1552 return false; |
| 1539 } | 1553 } |
| 1540 | 1554 |
| 1541 void RenderThemeChromiumMac::setSearchCellState(RenderObject* o, const IntRect&) | 1555 void RenderThemeChromiumMac::setSearchCellState(RenderObject* o, const IntRect&) |
| 1542 { | 1556 { |
| 1543 NSSearchFieldCell* search = this->search(); | 1557 NSSearchFieldCell* search = this->search(); |
| 1544 | 1558 |
| 1545 [search setControlSize:controlSizeForFont(o->style())]; | |
| 1546 | |
| 1547 // Update the various states we respond to. | 1559 // Update the various states we respond to. |
| 1548 updateActiveState(search, o); | 1560 updateActiveState(search, o); |
| 1549 updateEnabledState(search, o); | 1561 updateEnabledState(search, o); |
| 1550 updateFocusedState(search, o); | 1562 updateFocusedState(search, o); |
| 1551 } | 1563 } |
| 1552 | 1564 |
| 1553 const IntSize* RenderThemeChromiumMac::searchFieldSizes() const | 1565 const IntSize* RenderThemeChromiumMac::searchFieldSizes() const |
| 1554 { | 1566 { |
| 1555 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17) }; | 1567 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17) }; |
| 1556 return sizes; | 1568 return sizes; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1600 bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) | 1612 bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) |
| 1601 { | 1613 { |
| 1602 Element* input = o->node()->shadowHost(); | 1614 Element* input = o->node()->shadowHost(); |
| 1603 if (!input) | 1615 if (!input) |
| 1604 input = toElement(o->node()); | 1616 input = toElement(o->node()); |
| 1605 | 1617 |
| 1606 if (!input->renderer()->isBox()) | 1618 if (!input->renderer()->isBox()) |
| 1607 return false; | 1619 return false; |
| 1608 | 1620 |
| 1609 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1621 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1610 setSearchCellState(input->renderer(), r); | |
| 1611 | 1622 |
| 1612 NSSearchFieldCell* search = this->search(); | 1623 NSSearchFieldCell* search = this->search(); |
| 1624 setSearchCellState(input->renderer(), r); | |
| 1625 [search setControlSize:cancelButtonControlSizeForFont(o->style())]; | |
| 1613 | 1626 |
| 1614 if (!input->isDisabledFormControl() && (input->isTextFormControl() && !toHTM LTextFormControlElement(input)->isReadOnly())) { | 1627 if (!input->isDisabledFormControl() && (input->isTextFormControl() && !toHTM LTextFormControlElement(input)->isReadOnly())) { |
| 1615 updateActiveState([search cancelButtonCell], o); | 1628 updateActiveState([search cancelButtonCell], o); |
| 1616 updatePressedState([search cancelButtonCell], o); | 1629 updatePressedState([search cancelButtonCell], o); |
| 1617 } | 1630 } |
| 1618 else if ([[search cancelButtonCell] isHighlighted]) | 1631 else if ([[search cancelButtonCell] isHighlighted]) |
| 1619 [[search cancelButtonCell] setHighlighted:NO]; | 1632 [[search cancelButtonCell] setHighlighted:NO]; |
| 1620 | 1633 |
| 1621 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1634 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 1622 | 1635 |
| 1623 float zoomLevel = o->style()->effectiveZoom(); | 1636 float zoomLevel = o->style()->effectiveZoom(); |
| 1624 | 1637 FloatRect unzoomedRect(r); |
| 1625 FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(input->rend erBox()->pixelSnappedBorderBoxRect())]; | |
| 1626 | |
| 1627 #if ENABLE(INPUT_SPEECH) | |
|
tkent
2013/05/27 22:44:50
Is this code unnecessary?
keishi
2013/05/28 03:21:57
This is to avoid drawing where the speech button i
| |
| 1628 // Take care of cases where the cancel button was not aligned with the right border of the input element (for e.g. | |
| 1629 // when speech input is enabled for the input element. | |
| 1630 IntRect absBoundingBox = input->renderer()->absoluteBoundingBoxRect(); | |
| 1631 int absRight = absBoundingBox.x() + absBoundingBox.width() - input->renderBo x()->paddingRight() - input->renderBox()->borderRight(); | |
| 1632 int spaceToRightOfCancelButton = absRight - (r.x() + r.width()); | |
| 1633 localBounds.setX(localBounds.x() - spaceToRightOfCancelButton); | |
| 1634 #endif | |
| 1635 | |
| 1636 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); | |
| 1637 | |
| 1638 FloatRect unzoomedRect(localBounds); | |
| 1639 if (zoomLevel != 1.0f) { | 1638 if (zoomLevel != 1.0f) { |
| 1640 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1639 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1641 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1640 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1642 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1641 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1643 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1642 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1644 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1643 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1645 } | 1644 } |
| 1646 | 1645 |
| 1647 [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor (o)]; | 1646 [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor (o)]; |
| 1648 [[search cancelButtonCell] setControlView:nil]; | 1647 [[search cancelButtonCell] setControlView:nil]; |
| 1649 return false; | 1648 return false; |
| 1650 } | 1649 } |
| 1651 | 1650 |
| 1652 const IntSize* RenderThemeChromiumMac::cancelButtonSizes() const | 1651 const IntSize* RenderThemeChromiumMac::cancelButtonSizes() const |
| 1653 { | 1652 { |
| 1654 static const IntSize sizes[3] = { IntSize(16, 13), IntSize(13, 11), IntSize( 13, 9) }; | 1653 static const IntSize sizes[3] = { IntSize(16, 14), IntSize(13, 11), IntSize( 13, 9) }; |
| 1655 return sizes; | 1654 return sizes; |
| 1656 } | 1655 } |
| 1657 | 1656 |
| 1658 void RenderThemeChromiumMac::adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle* style, Element*) const | 1657 void RenderThemeChromiumMac::adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle* style, Element*) const |
| 1659 { | 1658 { |
| 1660 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); | 1659 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); |
| 1661 style->setWidth(Length(size.width(), Fixed)); | 1660 style->setWidth(Length(size.width(), Fixed)); |
| 1662 style->setHeight(Length(size.height(), Fixed)); | 1661 style->setHeight(Length(size.height(), Fixed)); |
| 1663 style->setBoxShadow(nullptr); | 1662 style->setBoxShadow(nullptr); |
| 1664 } | 1663 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1693 | 1692 |
| 1694 bool RenderThemeChromiumMac::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) | 1693 bool RenderThemeChromiumMac::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) |
| 1695 { | 1694 { |
| 1696 Node* input = o->node()->shadowHost(); | 1695 Node* input = o->node()->shadowHost(); |
| 1697 if (!input) | 1696 if (!input) |
| 1698 input = o->node(); | 1697 input = o->node(); |
| 1699 if (!input->renderer()->isBox()) | 1698 if (!input->renderer()->isBox()) |
| 1700 return false; | 1699 return false; |
| 1701 | 1700 |
| 1702 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1701 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1703 setSearchCellState(input->renderer(), r); | |
| 1704 | 1702 |
| 1705 NSSearchFieldCell* search = this->search(); | 1703 NSSearchFieldCell* search = this->search(); |
| 1704 setSearchCellState(input->renderer(), r); | |
| 1705 [search setControlSize:controlSizeForFont(o->style())]; | |
| 1706 | 1706 |
| 1707 if ([search searchMenuTemplate] != nil) | 1707 if ([search searchMenuTemplate] != nil) |
| 1708 [search setSearchMenuTemplate:nil]; | 1708 [search setSearchMenuTemplate:nil]; |
| 1709 | 1709 |
| 1710 updateActiveState([search searchButtonCell], o); | 1710 updateActiveState([search searchButtonCell], o); |
| 1711 | 1711 |
| 1712 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(input->rend erBox()->pixelSnappedBorderBoxRect())]; | 1712 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(input->rend erBox()->pixelSnappedBorderBoxRect())]; |
| 1713 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); | 1713 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); |
| 1714 | 1714 |
| 1715 [[search searchButtonCell] drawWithFrame:localBounds inView:documentViewFor( o)]; | 1715 [[search searchButtonCell] drawWithFrame:localBounds inView:documentViewFor( o)]; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1956 { | 1956 { |
| 1957 return RenderMediaControlsChromium::paintMediaControlsPart(MediaEnterFullscr eenButton, object, paintInfo, rect); | 1957 return RenderMediaControlsChromium::paintMediaControlsPart(MediaEnterFullscr eenButton, object, paintInfo, rect); |
| 1958 } | 1958 } |
| 1959 | 1959 |
| 1960 bool RenderThemeChromiumMac::paintMediaToggleClosedCaptionsButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) | 1960 bool RenderThemeChromiumMac::paintMediaToggleClosedCaptionsButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) |
| 1961 { | 1961 { |
| 1962 return RenderMediaControlsChromium::paintMediaControlsPart(MediaShowClosedCa ptionsButton, object, paintInfo, rect); | 1962 return RenderMediaControlsChromium::paintMediaControlsPart(MediaShowClosedCa ptionsButton, object, paintInfo, rect); |
| 1963 } | 1963 } |
| 1964 | 1964 |
| 1965 } // namespace WebCore | 1965 } // namespace WebCore |
| OLD | NEW |