Changeset 194817 in webkit
- Timestamp:
- Jan 8, 2016 10:27:42 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r194815 r194817 1 2016-01-08 Zalan Bujtas <zalan@apple.com> 2 3 Absolute positioning -webkit-search-cancel-button crashes Safari. 4 https://bugs.webkit.org/show_bug.cgi?id=152847 5 <rdar://problem/24112087> 6 7 Reviewed by Simon Fraser. 8 9 Do not call offsetFromContainer while resolving the painting position for the search/cancel button renderer. 10 It skips the static positioned parent input renderer, when the search/cancel renderer is absolute positioned. 11 This patch also fixes a rendering glitch when the margin-right is > 0. 12 13 * fast/forms/absolute-positioned-custom-search-cancel-crash-expected.txt: Added. 14 * fast/forms/absolute-positioned-custom-search-cancel-crash.html: Added. 15 1 16 2016-01-08 Brady Eidson <beidson@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r194816 r194817 1 2016-01-08 Zalan Bujtas <zalan@apple.com> 2 3 Absolute positioning -webkit-search-cancel-button crashes Safari. 4 https://bugs.webkit.org/show_bug.cgi?id=152847 5 <rdar://problem/24112087> 6 7 Reviewed by Simon Fraser. 8 9 Do not call offsetFromContainer while resolving the painting position for the search/cancel button renderer. 10 It skips the static positioned parent input renderer, when the search/cancel renderer is absolute positioned. 11 This patch also fixes a rendering glitch when the margin-right is > 0. 12 13 Test: fast/forms/absolute-positioned-custom-search-cancel-crash.html 14 15 * rendering/RenderTheme.h: 16 (WebCore::RenderTheme::paintSearchFieldCancelButton): 17 (WebCore::RenderTheme::paintSearchFieldResultsDecorationPart): 18 (WebCore::RenderTheme::paintSearchFieldResultsButton): 19 * rendering/RenderThemeMac.h: 20 * rendering/RenderThemeMac.mm: 21 (WebCore::convertToPaintingPosition): 22 (WebCore::RenderThemeMac::paintSearchFieldCancelButton): 23 (WebCore::RenderThemeMac::paintSearchFieldResultsDecorationPart): 24 (WebCore::RenderThemeMac::paintSearchFieldResultsButton): 25 (WebCore::RenderThemeMac::convertToPaintingRect): Deleted. 26 1 27 2016-01-08 Simon Fraser <simon.fraser@apple.com> 2 28 -
trunk/Source/WebCore/rendering/RenderTheme.h
r194318 r194817 339 339 340 340 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const; 341 virtual bool paintSearchFieldCancelButton(const Render Object&, const PaintInfo&, const IntRect&) { return true; }341 virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) { return true; } 342 342 343 343 virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const; … … 345 345 346 346 virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const; 347 virtual bool paintSearchFieldResultsDecorationPart(const Render Object&, const PaintInfo&, const IntRect&) { return true; }347 virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) { return true; } 348 348 349 349 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const; 350 virtual bool paintSearchFieldResultsButton(const Render Object&, const PaintInfo&, const IntRect&) { return true; }350 virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) { return true; } 351 351 352 352 virtual void adjustMediaControlStyle(StyleResolver&, RenderStyle&, Element*) const; -
trunk/Source/WebCore/rendering/RenderThemeEfl.cpp
r194496 r194817 933 933 } 934 934 935 bool RenderThemeEfl::paintSearchFieldResultsButton(const Render Object& object, const PaintInfo& info, const IntRect& rect)935 bool RenderThemeEfl::paintSearchFieldResultsButton(const RenderBox& object, const PaintInfo& info, const IntRect& rect) 936 936 { 937 937 return paintThemePart(object, SearchFieldResultsButton, info, rect); … … 955 955 } 956 956 957 bool RenderThemeEfl::paintSearchFieldResultsDecorationPart(const Render Object& object, const PaintInfo& info, const IntRect& rect)957 bool RenderThemeEfl::paintSearchFieldResultsDecorationPart(const RenderBox& object, const PaintInfo& info, const IntRect& rect) 958 958 { 959 959 return paintThemePart(object, SearchFieldResultsDecoration, info, rect); … … 979 979 } 980 980 981 bool RenderThemeEfl::paintSearchFieldCancelButton(const Render Object& object, const PaintInfo& info, const IntRect& rect)981 bool RenderThemeEfl::paintSearchFieldCancelButton(const RenderBox& object, const PaintInfo& info, const IntRect& rect) 982 982 { 983 983 return paintThemePart(object, SearchFieldCancelButton, info, rect); -
trunk/Source/WebCore/rendering/RenderThemeEfl.h
r189830 r194817 131 131 132 132 virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override; 133 virtual bool paintSearchFieldResultsDecorationPart(const Render Object&, const PaintInfo&, const IntRect&) override;133 virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override; 134 134 135 135 virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, Element*) const override; … … 137 137 138 138 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 139 virtual bool paintSearchFieldResultsButton(const Render Object&, const PaintInfo&, const IntRect&) override;139 virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 140 140 141 141 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 142 virtual bool paintSearchFieldCancelButton(const Render Object&, const PaintInfo&, const IntRect&) override;142 virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 143 143 144 144 virtual void adjustSliderTrackStyle(StyleResolver&, RenderStyle&, Element*) const override; -
trunk/Source/WebCore/rendering/RenderThemeGtk.cpp
r194377 r194817 1003 1003 } 1004 1004 1005 bool RenderThemeGtk::paintSearchFieldResultsButton(const Render Object& o, const PaintInfo& i, const IntRect& rect)1005 bool RenderThemeGtk::paintSearchFieldResultsButton(const RenderBox& o, const PaintInfo& i, const IntRect& rect) 1006 1006 { 1007 1007 return paintSearchFieldResultsDecorationPart(o, i, rect); … … 1054 1054 } 1055 1055 1056 bool RenderThemeGtk::paintSearchFieldResultsDecorationPart(const Render Object& renderObject, const PaintInfo& paintInfo, const IntRect& rect)1056 bool RenderThemeGtk::paintSearchFieldResultsDecorationPart(const RenderBox& renderObject, const PaintInfo& paintInfo, const IntRect& rect) 1057 1057 { 1058 1058 IntRect iconRect = centerRectVerticallyInParentInputElement(renderObject, rect); … … 1073 1073 } 1074 1074 1075 bool RenderThemeGtk::paintSearchFieldCancelButton(const Render Object& renderObject, const PaintInfo& paintInfo, const IntRect& rect)1075 bool RenderThemeGtk::paintSearchFieldCancelButton(const RenderBox& renderObject, const PaintInfo& paintInfo, const IntRect& rect) 1076 1076 { 1077 1077 IntRect iconRect = centerRectVerticallyInParentInputElement(renderObject, rect); -
trunk/Source/WebCore/rendering/RenderThemeGtk.h
r189830 r194817 134 134 135 135 virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override; 136 virtual bool paintSearchFieldResultsDecorationPart(const Render Object&, const PaintInfo&, const IntRect&) override;136 virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override; 137 137 138 138 virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, Element*) const override; … … 140 140 141 141 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 142 virtual bool paintSearchFieldResultsButton(const Render Object&, const PaintInfo&, const IntRect&) override;142 virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 143 143 144 144 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 145 virtual bool paintSearchFieldCancelButton(const Render Object&, const PaintInfo&, const IntRect&) override;145 virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 146 146 147 147 virtual bool paintSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) override; -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r194318 r194817 145 145 146 146 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 147 virtual bool paintSearchFieldCancelButton(const Render Object&, const PaintInfo&, const IntRect&) override;147 virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 148 148 149 149 virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override; … … 151 151 152 152 virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override; 153 virtual bool paintSearchFieldResultsDecorationPart(const Render Object&, const PaintInfo&, const IntRect&) override;153 virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override; 154 154 155 155 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 156 virtual bool paintSearchFieldResultsButton(const Render Object&, const PaintInfo&, const IntRect&) override;156 virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 157 157 158 158 #if ENABLE(VIDEO) … … 172 172 private: 173 173 virtual String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const override; 174 175 FloatRect convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect&) const;176 174 177 175 virtual Color systemColor(CSSValueID) const override; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r194496 r194817 674 674 } 675 675 676 FloatRect RenderThemeMac::convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect& r) const 677 { 678 FloatRect partRect(inputRect); 679 680 // Compute an offset between the part renderer and the input renderer 681 FloatSize offsetFromInputRenderer; 682 const RenderObject* renderer = &partRenderer; 683 while (renderer && renderer != &inputRenderer) { 684 RenderElement* containingRenderer = renderer->container(); 685 ASSERT(containingRenderer); 686 offsetFromInputRenderer -= roundedIntSize(renderer->offsetFromContainer(*containingRenderer, LayoutPoint())); 687 renderer = containingRenderer; 688 } 689 // If the input renderer was not a container, something went wrong 690 ASSERT(renderer == &inputRenderer); 691 // Move the rect into partRenderer's coords 692 partRect.move(offsetFromInputRenderer); 693 // Account for the local drawing offset (tx, ty) 694 partRect.move(r.x(), r.y()); 695 696 return partRect; 676 static FloatPoint convertToPaintingPosition(const RenderBox& inputRenderer, const RenderBox& customButtonRenderer, const FloatPoint& customButtonLocalPosition, 677 const IntPoint& paintOffset) 678 { 679 IntPoint offsetFromInputRenderer = roundedIntPoint(customButtonRenderer.localToContainerPoint(customButtonRenderer.contentBoxRect().location(), &inputRenderer)); 680 FloatPoint paintingPosition = customButtonLocalPosition; 681 paintingPosition.moveBy(-offsetFromInputRenderer); 682 paintingPosition.moveBy(paintOffset); 683 return paintingPosition; 697 684 } 698 685 … … 1675 1662 } 1676 1663 1677 bool RenderThemeMac::paintSearchFieldCancelButton(const Render Object& o, const PaintInfo& paintInfo, const IntRect& r)1678 { 1679 if (! o.node())1664 bool RenderThemeMac::paintSearchFieldCancelButton(const RenderBox& box, const PaintInfo& paintInfo, const IntRect& r) 1665 { 1666 if (!box.element()) 1680 1667 return false; 1681 Element* input = o.node()->shadowHost();1668 Element* input = box.element()->shadowHost(); 1682 1669 if (!input) 1683 input = downcast<Element>(o.node());1684 1685 if (!i nput->renderer()->isBox())1670 input = box.element(); 1671 1672 if (!is<RenderBox>(input->renderer())) 1686 1673 return false; 1687 1674 1675 const RenderBox& inputBox = downcast<RenderBox>(*input->renderer()); 1688 1676 LocalCurrentGraphicsContext localContext(paintInfo.context()); 1689 setSearchCellState( *input->renderer(), r);1677 setSearchCellState(inputBox, r); 1690 1678 1691 1679 NSSearchFieldCell* search = this->search(); 1692 1680 1693 1681 if (!input->isDisabledFormControl() && (is<HTMLTextFormControlElement>(*input) && !downcast<HTMLTextFormControlElement>(*input).isReadOnly())) 1694 updatePressedState([search cancelButtonCell], o);1682 updatePressedState([search cancelButtonCell], box); 1695 1683 else if ([[search cancelButtonCell] isHighlighted]) 1696 1684 [[search cancelButtonCell] setHighlighted:NO]; … … 1698 1686 GraphicsContextStateSaver stateSaver(paintInfo.context()); 1699 1687 1700 float zoomLevel = o.style().effectiveZoom();1701 1702 FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(snappedIntRect(input ->renderBox()->contentBoxRect()))];1703 localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);1704 1705 FloatRect unzoomedRect( localBounds);1688 float zoomLevel = box.style().effectiveZoom(); 1689 1690 FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(snappedIntRect(inputBox.contentBoxRect()))]; 1691 FloatPoint paintingPos = convertToPaintingPosition(inputBox, box, localBounds.location(), r.location()); 1692 1693 FloatRect unzoomedRect(paintingPos, localBounds.size()); 1706 1694 if (zoomLevel != 1.0f) { 1707 1695 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); … … 1712 1700 } 1713 1701 1714 [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor( o)];1702 [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(box)]; 1715 1703 [[search cancelButtonCell] setControlView:nil]; 1716 1704 return false; … … 1759 1747 } 1760 1748 1761 bool RenderThemeMac::paintSearchFieldResultsDecorationPart(const Render Object& o, const PaintInfo& paintInfo, const IntRect& r)1762 { 1763 if (! o.node())1749 bool RenderThemeMac::paintSearchFieldResultsDecorationPart(const RenderBox& box, const PaintInfo& paintInfo, const IntRect& r) 1750 { 1751 if (!box.element()) 1764 1752 return false; 1765 Node* input = o.node()->shadowHost();1753 Element* input = box.element()->shadowHost(); 1766 1754 if (!input) 1767 input = o.node();1768 if (!i nput->renderer()->isBox())1755 input = box.element(); 1756 if (!is<RenderBox>(input->renderer())) 1769 1757 return false; 1770 1758 1759 const RenderBox& inputBox = downcast<RenderBox>(*input->renderer()); 1771 1760 LocalCurrentGraphicsContext localContext(paintInfo.context()); 1772 setSearchCellState( *input->renderer(), r);1761 setSearchCellState(inputBox, r); 1773 1762 1774 1763 NSSearchFieldCell* search = this->search(); … … 1777 1766 [search setSearchMenuTemplate:nil]; 1778 1767 1779 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->borderBoxRect()))]; 1780 localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r); 1781 1782 [[search searchButtonCell] drawWithFrame:localBounds inView:documentViewFor(o)]; 1768 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(inputBox.borderBoxRect()))]; 1769 FloatPoint paintingPos = convertToPaintingPosition(inputBox, box, localBounds.location(), r.location()); 1770 localBounds.setLocation(paintingPos); 1771 1772 [[search searchButtonCell] drawWithFrame:localBounds inView:documentViewFor(box)]; 1783 1773 [[search searchButtonCell] setControlView:nil]; 1784 1774 return false; … … 1794 1784 } 1795 1785 1796 bool RenderThemeMac::paintSearchFieldResultsButton(const Render Object& o, const PaintInfo& paintInfo, const IntRect& r)1797 { 1798 Node* input = o.node()->shadowHost();1786 bool RenderThemeMac::paintSearchFieldResultsButton(const RenderBox& box, const PaintInfo& paintInfo, const IntRect& r) 1787 { 1788 Element* input = box.element()->shadowHost(); 1799 1789 if (!input) 1800 input = o.node();1801 if (!i nput->renderer()->isBox())1790 input = box.element(); 1791 if (!is<RenderBox>(input->renderer())) 1802 1792 return false; 1803 1793 1794 const RenderBox& inputBox = downcast<RenderBox>(*input->renderer()); 1804 1795 LocalCurrentGraphicsContext localContext(paintInfo.context()); 1805 setSearchCellState( *input->renderer(), r);1796 setSearchCellState(inputBox, r); 1806 1797 1807 1798 NSSearchFieldCell* search = this->search(); … … 1811 1802 1812 1803 GraphicsContextStateSaver stateSaver(paintInfo.context()); 1813 float zoomLevel = o.style().effectiveZoom();1814 1815 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(input ->renderBox()->contentBoxRect()))];1816 localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);1817 1818 IntRect unzoomedRect(localBounds);1804 float zoomLevel = box.style().effectiveZoom(); 1805 1806 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(inputBox.contentBoxRect()))]; 1807 FloatPoint paintingPos = convertToPaintingPosition(inputBox, box, localBounds.location(), r.location()); 1808 1809 FloatRect unzoomedRect(paintingPos, localBounds.size()); 1819 1810 if (zoomLevel != 1.0f) { 1820 1811 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); … … 1825 1816 } 1826 1817 1827 [[search searchButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor( o)];1818 [[search searchButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(box)]; 1828 1819 [[search searchButtonCell] setControlView:nil]; 1829 1820 -
trunk/Source/WebCore/rendering/RenderThemeWin.cpp
r192143 r194817 874 874 } 875 875 876 bool RenderThemeWin::paintSearchFieldCancelButton(const Render Object& o, const PaintInfo& paintInfo, const IntRect& r)876 bool RenderThemeWin::paintSearchFieldCancelButton(const RenderBox& o, const PaintInfo& paintInfo, const IntRect& r) 877 877 { 878 878 IntRect bounds = r; … … 923 923 } 924 924 925 bool RenderThemeWin::paintSearchFieldResultsDecorationPart(const Render Object& o, const PaintInfo& paintInfo, const IntRect& r)925 bool RenderThemeWin::paintSearchFieldResultsDecorationPart(const RenderBox& o, const PaintInfo& paintInfo, const IntRect& r) 926 926 { 927 927 IntRect bounds = r; … … 956 956 } 957 957 958 bool RenderThemeWin::paintSearchFieldResultsButton(const Render Object& o, const PaintInfo& paintInfo, const IntRect& r)958 bool RenderThemeWin::paintSearchFieldResultsButton(const RenderBox& o, const PaintInfo& paintInfo, const IntRect& r) 959 959 { 960 960 IntRect bounds = r; -
trunk/Source/WebCore/rendering/RenderThemeWin.h
r189830 r194817 100 100 101 101 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 102 virtual bool paintSearchFieldCancelButton(const Render Object&, const PaintInfo&, const IntRect&) override;102 virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 103 103 104 104 virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override; … … 106 106 107 107 virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override; 108 virtual bool paintSearchFieldResultsDecorationPart(const Render Object&, const PaintInfo&, const IntRect&) override;108 virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override; 109 109 110 110 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override; 111 virtual bool paintSearchFieldResultsButton(const Render Object&, const PaintInfo&, const IntRect&) override;111 virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override; 112 112 113 113 virtual void themeChanged() override;
Note: See TracChangeset
for help on using the changeset viewer.