Absolute positioning -webkit-search-cancel-button crashes Safari.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jan 2016 06:27:42 +0000 (06:27 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jan 2016 06:27:42 +0000 (06:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152847
<rdar://problem/24112087>

Reviewed by Simon Fraser.

Do not call offsetFromContainer while resolving the painting position for the search/cancel button renderer.
It skips the static positioned parent input renderer, when the search/cancel renderer is absolute positioned.
This patch also fixes a rendering glitch when the margin-right is > 0.

Source/WebCore:

Test: fast/forms/absolute-positioned-custom-search-cancel-crash.html

* rendering/RenderTheme.h:
(WebCore::RenderTheme::paintSearchFieldCancelButton):
(WebCore::RenderTheme::paintSearchFieldResultsDecorationPart):
(WebCore::RenderTheme::paintSearchFieldResultsButton):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::convertToPaintingPosition):
(WebCore::RenderThemeMac::paintSearchFieldCancelButton):
(WebCore::RenderThemeMac::paintSearchFieldResultsDecorationPart):
(WebCore::RenderThemeMac::paintSearchFieldResultsButton):
(WebCore::RenderThemeMac::convertToPaintingRect): Deleted.

LayoutTests:

* fast/forms/absolute-positioned-custom-search-cancel-crash-expected.txt: Added.
* fast/forms/absolute-positioned-custom-search-cancel-crash.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194817 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/absolute-positioned-custom-search-cancel-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/absolute-positioned-custom-search-cancel-crash.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeEfl.cpp
Source/WebCore/rendering/RenderThemeEfl.h
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeGtk.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderThemeWin.cpp
Source/WebCore/rendering/RenderThemeWin.h

index ed799b1..e16dcd9 100644 (file)
@@ -1,3 +1,18 @@
+2016-01-08  Zalan Bujtas  <zalan@apple.com>
+
+        Absolute positioning -webkit-search-cancel-button crashes Safari.
+        https://bugs.webkit.org/show_bug.cgi?id=152847
+        <rdar://problem/24112087>
+
+        Reviewed by Simon Fraser.
+
+        Do not call offsetFromContainer while resolving the painting position for the search/cancel button renderer.
+        It skips the static positioned parent input renderer, when the search/cancel renderer is absolute positioned.
+        This patch also fixes a rendering glitch when the margin-right is > 0.
+
+        * fast/forms/absolute-positioned-custom-search-cancel-crash-expected.txt: Added.
+        * fast/forms/absolute-positioned-custom-search-cancel-crash.html: Added.
+
 2016-01-08  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: storage/indexeddb/setversion-blocked-by-versionchange-close.html fails.
diff --git a/LayoutTests/fast/forms/absolute-positioned-custom-search-cancel-crash-expected.txt b/LayoutTests/fast/forms/absolute-positioned-custom-search-cancel-crash-expected.txt
new file mode 100644 (file)
index 0000000..4c5caa9
--- /dev/null
@@ -0,0 +1 @@
+PASS if no crash. 
diff --git a/LayoutTests/fast/forms/absolute-positioned-custom-search-cancel-crash.html b/LayoutTests/fast/forms/absolute-positioned-custom-search-cancel-crash.html
new file mode 100644 (file)
index 0000000..9d31a7c
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that absolute positioned search/cancel button painting is not crashing</title>
+<style>
+#test {
+    border: 1px solid red;
+    padding-right: 20px;
+    padding-left: 50px;
+    -webkit-appearance: none;
+}
+
+#test::-webkit-search-cancel-button {
+    position: absolute;
+}
+</style>
+</head>
+<body>
+PASS if no crash.
+<input id="test" type="search">
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+    document.getElementById("test").value = "foobar";
+</script>
+</body>
+</html>
index f6bbf0e..2656e6b 100644 (file)
@@ -1,3 +1,29 @@
+2016-01-08  Zalan Bujtas  <zalan@apple.com>
+
+        Absolute positioning -webkit-search-cancel-button crashes Safari.
+        https://bugs.webkit.org/show_bug.cgi?id=152847
+        <rdar://problem/24112087>
+
+        Reviewed by Simon Fraser.
+
+        Do not call offsetFromContainer while resolving the painting position for the search/cancel button renderer.
+        It skips the static positioned parent input renderer, when the search/cancel renderer is absolute positioned.
+        This patch also fixes a rendering glitch when the margin-right is > 0.
+
+        Test: fast/forms/absolute-positioned-custom-search-cancel-crash.html
+
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::paintSearchFieldCancelButton):
+        (WebCore::RenderTheme::paintSearchFieldResultsDecorationPart):
+        (WebCore::RenderTheme::paintSearchFieldResultsButton):
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::convertToPaintingPosition):
+        (WebCore::RenderThemeMac::paintSearchFieldCancelButton):
+        (WebCore::RenderThemeMac::paintSearchFieldResultsDecorationPart):
+        (WebCore::RenderThemeMac::paintSearchFieldResultsButton):
+        (WebCore::RenderThemeMac::convertToPaintingRect): Deleted.
+
 2016-01-08  Simon Fraser  <simon.fraser@apple.com>
 
         Add display-list drawing hooks to platform-specific GraphicsContext files
index 8d9167a..5a9d28b 100644 (file)
@@ -338,16 +338,16 @@ protected:
     virtual bool paintSearchFieldDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
 
     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const;
-    virtual bool paintSearchFieldCancelButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+    virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) { return true; }
 
     virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const;
     virtual bool paintSearchFieldDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const;
-    virtual bool paintSearchFieldResultsDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+    virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) { return true; }
 
     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const;
-    virtual bool paintSearchFieldResultsButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+    virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) { return true; }
 
     virtual void adjustMediaControlStyle(StyleResolver&, RenderStyle&, Element*) const;
     virtual bool paintMediaFullscreenButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
index b3bb722..c1e79d3 100644 (file)
@@ -932,7 +932,7 @@ void RenderThemeEfl::adjustSearchFieldResultsButtonStyle(StyleResolver& styleRes
     style.setHeight(Length(decorationSize, Fixed));
 }
 
-bool RenderThemeEfl::paintSearchFieldResultsButton(const RenderObject& object, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeEfl::paintSearchFieldResultsButton(const RenderBox& object, const PaintInfo& info, const IntRect& rect)
 {
     return paintThemePart(object, SearchFieldResultsButton, info, rect);
 }
@@ -954,7 +954,7 @@ void RenderThemeEfl::adjustSearchFieldResultsDecorationPartStyle(StyleResolver&
     style.setHeight(Length(decorationSize, Fixed));
 }
 
-bool RenderThemeEfl::paintSearchFieldResultsDecorationPart(const RenderObject& object, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeEfl::paintSearchFieldResultsDecorationPart(const RenderBox& object, const PaintInfo& info, const IntRect& rect)
 {
     return paintThemePart(object, SearchFieldResultsDecoration, info, rect);
 }
@@ -978,7 +978,7 @@ void RenderThemeEfl::adjustSearchFieldCancelButtonStyle(StyleResolver& styleReso
     style.setHeight(Length(cancelButtonSize, Fixed));
 }
 
-bool RenderThemeEfl::paintSearchFieldCancelButton(const RenderObject& object, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeEfl::paintSearchFieldCancelButton(const RenderBox& object, const PaintInfo& info, const IntRect& rect)
 {
     return paintThemePart(object, SearchFieldCancelButton, info, rect);
 }
index 81db81e..135e9f0 100644 (file)
@@ -130,16 +130,16 @@ public:
     virtual bool paintMenuListButtonDecorations(const RenderBox&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, Element*) const override;
     virtual bool paintSearchField(const RenderObject&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldCancelButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSliderTrackStyle(StyleResolver&, RenderStyle&, Element*) const override;
     virtual bool paintSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) override;
index bd7ffa2..08249a7 100644 (file)
@@ -1002,7 +1002,7 @@ void RenderThemeGtk::adjustSearchFieldResultsButtonStyle(StyleResolver& styleRes
     adjustSearchFieldCancelButtonStyle(styleResolver, style, e);
 }
 
-bool RenderThemeGtk::paintSearchFieldResultsButton(const RenderObject& o, const PaintInfo& i, const IntRect& rect)
+bool RenderThemeGtk::paintSearchFieldResultsButton(const RenderBox& o, const PaintInfo& i, const IntRect& rect)
 {
     return paintSearchFieldResultsDecorationPart(o, i, rect);
 }
@@ -1053,7 +1053,7 @@ static IntRect centerRectVerticallyInParentInputElement(const RenderObject& rend
     return scaledRect;
 }
 
-bool RenderThemeGtk::paintSearchFieldResultsDecorationPart(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+bool RenderThemeGtk::paintSearchFieldResultsDecorationPart(const RenderBox& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
     IntRect iconRect = centerRectVerticallyInParentInputElement(renderObject, rect);
     if (iconRect.isEmpty())
@@ -1072,7 +1072,7 @@ void RenderThemeGtk::adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderSt
     adjustSearchFieldIconStyle(style);
 }
 
-bool RenderThemeGtk::paintSearchFieldCancelButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+bool RenderThemeGtk::paintSearchFieldCancelButton(const RenderBox& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
     IntRect iconRect = centerRectVerticallyInParentInputElement(renderObject, rect);
     if (iconRect.isEmpty())
index 207b4d7..070b396 100644 (file)
@@ -133,16 +133,16 @@ private:
     virtual bool paintMenuListButtonDecorations(const RenderBox&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, Element*) const override;
     virtual bool paintSearchField(const RenderObject&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldCancelButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual bool paintSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) override;
     virtual void adjustSliderTrackStyle(StyleResolver&, RenderStyle&, Element*) const override;
index 3dd8824..9e247c3 100644 (file)
@@ -144,16 +144,16 @@ protected:
     virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, Element*) const override;
 
     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldCancelButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override;
     virtual bool paintSearchFieldDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
 #if ENABLE(VIDEO)
     virtual bool supportsClosedCaptioning() const override { return true; }
@@ -172,8 +172,6 @@ protected:
 private:
     virtual String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const override;
 
-    FloatRect convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect&) const;
-
     virtual Color systemColor(CSSValueID) const override;
 
     // Get the control size based off the font. Used by some of the controls (like buttons).
index 3043ad2..ad10f27 100644 (file)
@@ -673,27 +673,14 @@ void RenderThemeMac::adjustRepaintRect(const RenderObject& renderer, FloatRect&
     }
 }
 
-FloatRect RenderThemeMac::convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect& r) const
-{
-    FloatRect partRect(inputRect);
-
-    // Compute an offset between the part renderer and the input renderer
-    FloatSize offsetFromInputRenderer;
-    const RenderObject* renderer = &partRenderer;
-    while (renderer && renderer != &inputRenderer) {
-        RenderElement* containingRenderer = renderer->container();
-        ASSERT(containingRenderer);
-        offsetFromInputRenderer -= roundedIntSize(renderer->offsetFromContainer(*containingRenderer, LayoutPoint()));
-        renderer = containingRenderer;
-    }
-    // If the input renderer was not a container, something went wrong
-    ASSERT(renderer == &inputRenderer);
-    // Move the rect into partRenderer's coords
-    partRect.move(offsetFromInputRenderer);
-    // Account for the local drawing offset (tx, ty)
-    partRect.move(r.x(), r.y());
-
-    return partRect;
+static FloatPoint convertToPaintingPosition(const RenderBox& inputRenderer, const RenderBox& customButtonRenderer, const FloatPoint& customButtonLocalPosition,
+    const IntPoint& paintOffset)
+{
+    IntPoint offsetFromInputRenderer = roundedIntPoint(customButtonRenderer.localToContainerPoint(customButtonRenderer.contentBoxRect().location(), &inputRenderer));
+    FloatPoint paintingPosition = customButtonLocalPosition;
+    paintingPosition.moveBy(-offsetFromInputRenderer);
+    paintingPosition.moveBy(paintOffset);
+    return paintingPosition;
 }
 
 void RenderThemeMac::updateCheckedState(NSCell* cell, const RenderObject& o)
@@ -1674,35 +1661,36 @@ void RenderThemeMac::adjustSearchFieldStyle(StyleResolver& styleResolver, Render
     style.setBoxShadow(nullptr);
 }
 
-bool RenderThemeMac::paintSearchFieldCancelButton(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeMac::paintSearchFieldCancelButton(const RenderBox& box, const PaintInfo& paintInfo, const IntRect& r)
 {
-    if (!o.node())
+    if (!box.element())
         return false;
-    Element* input = o.node()->shadowHost();
+    Element* input = box.element()->shadowHost();
     if (!input)
-        input = downcast<Element>(o.node());
+        input = box.element();
 
-    if (!input->renderer()->isBox())
+    if (!is<RenderBox>(input->renderer()))
         return false;
 
+    const RenderBox& inputBox = downcast<RenderBox>(*input->renderer());
     LocalCurrentGraphicsContext localContext(paintInfo.context());
-    setSearchCellState(*input->renderer(), r);
+    setSearchCellState(inputBox, r);
 
     NSSearchFieldCell* search = this->search();
 
     if (!input->isDisabledFormControl() && (is<HTMLTextFormControlElement>(*input) && !downcast<HTMLTextFormControlElement>(*input).isReadOnly()))
-        updatePressedState([search cancelButtonCell], o);
+        updatePressedState([search cancelButtonCell], box);
     else if ([[search cancelButtonCell] isHighlighted])
         [[search cancelButtonCell] setHighlighted:NO];
 
     GraphicsContextStateSaver stateSaver(paintInfo.context());
 
-    float zoomLevel = o.style().effectiveZoom();
+    float zoomLevel = box.style().effectiveZoom();
 
-    FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->contentBoxRect()))];
-    localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);
+    FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(snappedIntRect(inputBox.contentBoxRect()))];
+    FloatPoint paintingPos = convertToPaintingPosition(inputBox, box, localBounds.location(), r.location());
 
-    FloatRect unzoomedRect(localBounds);
+    FloatRect unzoomedRect(paintingPos, localBounds.size());
     if (zoomLevel != 1.0f) {
         unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
         unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
@@ -1711,7 +1699,7 @@ bool RenderThemeMac::paintSearchFieldCancelButton(const RenderObject& o, const P
         paintInfo.context().translate(-unzoomedRect.x(), -unzoomedRect.y());
     }
 
-    [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(o)];
+    [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(box)];
     [[search cancelButtonCell] setControlView:nil];
     return false;
 }
@@ -1758,28 +1746,30 @@ void RenderThemeMac::adjustSearchFieldResultsDecorationPartStyle(StyleResolver&,
     style.setBoxShadow(nullptr);
 }
 
-bool RenderThemeMac::paintSearchFieldResultsDecorationPart(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeMac::paintSearchFieldResultsDecorationPart(const RenderBox& box, const PaintInfo& paintInfo, const IntRect& r)
 {
-    if (!o.node())
+    if (!box.element())
         return false;
-    Node* input = o.node()->shadowHost();
+    Element* input = box.element()->shadowHost();
     if (!input)
-        input = o.node();
-    if (!input->renderer()->isBox())
+        input = box.element();
+    if (!is<RenderBox>(input->renderer()))
         return false;
-
+    
+    const RenderBox& inputBox = downcast<RenderBox>(*input->renderer());
     LocalCurrentGraphicsContext localContext(paintInfo.context());
-    setSearchCellState(*input->renderer(), r);
+    setSearchCellState(inputBox, r);
 
     NSSearchFieldCell* search = this->search();
 
     if ([search searchMenuTemplate] != nil)
         [search setSearchMenuTemplate:nil];
 
-    FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->borderBoxRect()))];
-    localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);
+    FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(inputBox.borderBoxRect()))];
+    FloatPoint paintingPos = convertToPaintingPosition(inputBox, box, localBounds.location(), r.location());
+    localBounds.setLocation(paintingPos);
 
-    [[search searchButtonCell] drawWithFrame:localBounds inView:documentViewFor(o)];
+    [[search searchButtonCell] drawWithFrame:localBounds inView:documentViewFor(box)];
     [[search searchButtonCell] setControlView:nil];
     return false;
 }
@@ -1793,16 +1783,17 @@ void RenderThemeMac::adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderS
     style.setBoxShadow(nullptr);
 }
 
-bool RenderThemeMac::paintSearchFieldResultsButton(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeMac::paintSearchFieldResultsButton(const RenderBox& box, const PaintInfo& paintInfo, const IntRect& r)
 {
-    Node* input = o.node()->shadowHost();
+    Element* input = box.element()->shadowHost();
     if (!input)
-        input = o.node();
-    if (!input->renderer()->isBox())
+        input = box.element();
+    if (!is<RenderBox>(input->renderer()))
         return false;
-
+    
+    const RenderBox& inputBox = downcast<RenderBox>(*input->renderer());
     LocalCurrentGraphicsContext localContext(paintInfo.context());
-    setSearchCellState(*input->renderer(), r);
+    setSearchCellState(inputBox, r);
 
     NSSearchFieldCell* search = this->search();
 
@@ -1810,12 +1801,12 @@ bool RenderThemeMac::paintSearchFieldResultsButton(const RenderObject& o, const
         [search setSearchMenuTemplate:searchMenuTemplate()];
 
     GraphicsContextStateSaver stateSaver(paintInfo.context());
-    float zoomLevel = o.style().effectiveZoom();
-
-    FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->contentBoxRect()))];
-    localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);
+    float zoomLevel = box.style().effectiveZoom();
 
-    IntRect unzoomedRect(localBounds);
+    FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(inputBox.contentBoxRect()))];
+    FloatPoint paintingPos = convertToPaintingPosition(inputBox, box, localBounds.location(), r.location());
+    
+    FloatRect unzoomedRect(paintingPos, localBounds.size());
     if (zoomLevel != 1.0f) {
         unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
         unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
@@ -1824,7 +1815,7 @@ bool RenderThemeMac::paintSearchFieldResultsButton(const RenderObject& o, const
         paintInfo.context().translate(-unzoomedRect.x(), -unzoomedRect.y());
     }
 
-    [[search searchButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(o)];
+    [[search searchButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(box)];
     [[search searchButtonCell] setControlView:nil];
 
     return false;
index ac255da..b88e660 100644 (file)
@@ -873,7 +873,7 @@ void RenderThemeWin::adjustSearchFieldStyle(StyleResolver& styleResolver, Render
         style.setOutlineOffset(-2);
 }
 
-bool RenderThemeWin::paintSearchFieldCancelButton(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeWin::paintSearchFieldCancelButton(const RenderBox& o, const PaintInfo& paintInfo, const IntRect& r)
 {
     IntRect bounds = r;
     ASSERT(o.parent());
@@ -922,7 +922,7 @@ void RenderThemeWin::adjustSearchFieldResultsDecorationPartStyle(StyleResolver&,
     style.setHeight(Length(magnifierSize, Fixed));
 }
 
-bool RenderThemeWin::paintSearchFieldResultsDecorationPart(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeWin::paintSearchFieldResultsDecorationPart(const RenderBox& o, const PaintInfo& paintInfo, const IntRect& r)
 {
     IntRect bounds = r;
     ASSERT(o.parent());
@@ -955,7 +955,7 @@ void RenderThemeWin::adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderS
     style.setHeight(Length(magnifierHeight, Fixed));
 }
 
-bool RenderThemeWin::paintSearchFieldResultsButton(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeWin::paintSearchFieldResultsButton(const RenderBox& o, const PaintInfo& paintInfo, const IntRect& r)
 {
     IntRect bounds = r;
     ASSERT(o.parent());
index 4d98b74..0a7b18d 100644 (file)
@@ -99,16 +99,16 @@ public:
     virtual bool paintSearchField(const RenderObject&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldCancelButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override;
     virtual bool paintSearchFieldDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) override { return false; }
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element*) const override;
-    virtual bool paintSearchFieldResultsButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
 
     virtual void themeChanged() override;