Title: [169898] trunk/Source/WebCore
Revision
169898
Author
[email protected]
Date
2014-06-12 07:53:51 -0700 (Thu, 12 Jun 2014)

Log Message

Subpixel rendering: Make <select> element's decoration subpixel aware.
https://bugs.webkit.org/show_bug.cgi?id=133781
<rdar://problem/17272083>

Reviewed by Simon Fraser.

Enable <select> decoration painting on subpixel positions.
The theme size is still integral, but its position is snapped to device pixels.
Theme's label, the InlineTextBox is already subpixel position aware.
webkit.org/b/132005 tracks the rest of the themes.

Not testable.

* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::paint):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::paintMenuList):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::inflateRect):
(WebCore::RenderThemeMac::adjustRepaintRect):
(WebCore::RenderThemeMac::paintMenuList):
(WebCore::RenderThemeMac::progressBarRectForBounds):
(WebCore::RenderThemeMac::setPopupButtonCellState):
(WebCore::RenderThemeMac::inflateRect): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169897 => 169898)


--- trunk/Source/WebCore/ChangeLog	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/ChangeLog	2014-06-12 14:53:51 UTC (rev 169898)
@@ -1,3 +1,31 @@
+2014-06-12  Zalan Bujtas  <[email protected]>
+
+        Subpixel rendering: Make <select> element's decoration subpixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=133781
+        <rdar://problem/17272083>
+
+        Reviewed by Simon Fraser.
+
+        Enable <select> decoration painting on subpixel positions.
+        The theme size is still integral, but its position is snapped to device pixels.
+        Theme's label, the InlineTextBox is already subpixel position aware.
+        webkit.org/b/132005 tracks the rest of the themes.
+
+        Not testable.
+
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::paint):
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::paintMenuList):
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::inflateRect):
+        (WebCore::RenderThemeMac::adjustRepaintRect):
+        (WebCore::RenderThemeMac::paintMenuList):
+        (WebCore::RenderThemeMac::progressBarRectForBounds):
+        (WebCore::RenderThemeMac::setPopupButtonCellState):
+        (WebCore::RenderThemeMac::inflateRect): Deleted.
+
 2014-06-12  Jer Noble  <[email protected]>
 
         [MSE][Mac] Crash in MediaSourcePrivateAVFObjC::naturalSize()

Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp (169897 => 169898)


--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2014-06-12 14:53:51 UTC (rev 169898)
@@ -842,9 +842,9 @@
     style->setLineHeight(RenderStyle::initialLineHeight());
 }
 
-bool RenderThemeEfl::paintMenuList(const RenderObject& object, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeEfl::paintMenuList(const RenderObject& object, const PaintInfo& info, const FloatRect& rect)
 {
-    return paintThemePart(object, ComboBox, info, rect);
+    return paintThemePart(object, ComboBox, info, IntRect(rect));
 }
 
 void RenderThemeEfl::adjustMenuListButtonStyle(StyleResolver* styleResolver, RenderStyle* style, Element* element) const
@@ -865,7 +865,7 @@
 
 bool RenderThemeEfl::paintMenuListButtonDecorations(const RenderObject& object, const PaintInfo& info, const FloatRect& rect)
 {
-    return paintMenuList(object, info, IntRect(rect));
+    return paintMenuList(object, info, rect);
 }
 
 void RenderThemeEfl::adjustTextFieldStyle(StyleResolver* styleResolver, RenderStyle* style, Element* element) const

Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.h (169897 => 169898)


--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.h	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.h	2014-06-12 14:53:51 UTC (rev 169898)
@@ -126,7 +126,7 @@
     virtual bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const override;
-    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const override;
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp (169897 => 169898)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2014-06-12 14:53:51 UTC (rev 169898)
@@ -243,7 +243,7 @@
 
 bool RenderThemeGtk::paintMenuListButtonDecorations(const RenderObject& object, const PaintInfo& info, const FloatRect& rect)
 {
-    return paintMenuList(object, info, IntRect(rect));
+    return paintMenuList(object, info, rect);
 }
 
 bool RenderThemeGtk::paintTextArea(const RenderObject& o, const PaintInfo& i, const FloatRect& r)

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h (169897 => 169898)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h	2014-06-12 14:53:51 UTC (rev 169898)
@@ -137,7 +137,7 @@
     // we don't maintain this differentiation.
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const override;
     virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const override;
-    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) override;
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver*, RenderStyle*, Element*) const override;

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp (169897 => 169898)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp	2014-06-12 14:53:51 UTC (rev 169898)
@@ -365,8 +365,10 @@
     return bottom;
 }
 
-bool RenderThemeGtk::paintMenuList(const RenderObject& object, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeGtk::paintMenuList(const RenderObject& object, const PaintInfo& info, const FloatRect& r)
 {
+    // FIXME: adopt subpixel themes.
+    IntRect rect = IntRect(r);   
     if (paintButton(object, info, rect))
         return true;
 

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp (169897 => 169898)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp	2014-06-12 14:53:51 UTC (rev 169898)
@@ -464,8 +464,11 @@
     return borderWidth.bottom + focusWidth;
 }
 
-bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& r)
 {
+    // FIXME: adopt subpixel themes.
+    IntRect rect = IntRect(r);   
+
     cairo_t* cairoContext = paintInfo.context->platformContext()->cr();
     GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()));
 

Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (169897 => 169898)


--- trunk/Source/WebCore/rendering/RenderTheme.cpp	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp	2014-06-12 14:53:51 UTC (rev 169898)
@@ -278,6 +278,7 @@
 
     ControlPart part = o.style().appearance();
     IntRect integralSnappedRect = pixelSnappedIntRect(r);
+    FloatRect devicePixelSnappedRect = pixelSnappedForPainting(r, o.document().deviceScaleFactor());
 
 #if USE(NEW_THEME)
     switch (part) {
@@ -314,7 +315,7 @@
         return paintInnerSpinButton(o, paintInfo, integralSnappedRect);
 #endif
     case MenulistPart:
-        return paintMenuList(o, paintInfo, integralSnappedRect);
+        return paintMenuList(o, paintInfo, devicePixelSnappedRect);
 #if ENABLE(METER_ELEMENT)
     case MeterPart:
     case RelevancyLevelIndicatorPart:

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (169897 => 169898)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2014-06-12 14:53:51 UTC (rev 169898)
@@ -299,7 +299,7 @@
     virtual bool paintTextAreaDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
 
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const;
-    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
     virtual bool paintMenuListDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
 
     virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (169897 => 169898)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2014-06-12 14:53:51 UTC (rev 169898)
@@ -130,7 +130,7 @@
     virtual bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) override;
     virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const override;
 
-    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const IntRect&) override;
+    virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) override;
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const override;
 
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
@@ -173,8 +173,6 @@
 private:
     virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const override;
 
-    IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const;
-
     FloatRect convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect&) const;
 
     // Get the control size based off the font. Used by some of the controls (like buttons).
@@ -194,7 +192,7 @@
 
     // Helpers for adjusting appearance and for painting
 
-    void setPopupButtonCellState(const RenderObject&, const IntRect&);
+    void setPopupButtonCellState(const RenderObject&, const IntSize&);
     const IntSize* popupButtonSizes() const;
     const int* popupButtonMargins() const;
     const int* popupButtonPadding(NSControlSize) const;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (169897 => 169898)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2014-06-12 14:09:31 UTC (rev 169897)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2014-06-12 14:53:51 UTC (rev 169898)
@@ -615,6 +615,24 @@
     return RenderTheme::isControlStyled(style, border, background, backgroundColor);
 }
 
+static FloatRect inflateRect(const FloatRect& rect, const IntSize& size, const int* margins, float zoomLevel)
+{
+    // Only do the inflation if the available width/height are too small. Otherwise try to
+    // fit the glow/check space into the available box's width/height.
+    int widthDelta = rect.width() - (size.width() + margins[leftMargin] * zoomLevel + margins[rightMargin] * zoomLevel);
+    int heightDelta = rect.height() - (size.height() + margins[topMargin] * zoomLevel + margins[bottomMargin] * zoomLevel);
+    FloatRect result(rect);
+    if (widthDelta < 0) {
+        result.setX(result.x() - margins[leftMargin] * zoomLevel);
+        result.setWidth(result.width() - widthDelta);
+    }
+    if (heightDelta < 0) {
+        result.setY(result.y() - margins[topMargin] * zoomLevel);
+        result.setHeight(result.height() - heightDelta);
+    }
+    return result;
+}
+
 void RenderThemeMac::adjustRepaintRect(const RenderObject& o, IntRect& r)
 {
     ControlPart part = o.style().appearance();
@@ -637,32 +655,14 @@
     float zoomLevel = o.style().effectiveZoom();
 
     if (part == MenulistPart) {
-        setPopupButtonCellState(o, r);
+        setPopupButtonCellState(o, r.size());
         IntSize size = popupButtonSizes()[[popupButton() controlSize]];
         size.setHeight(size.height() * zoomLevel);
         size.setWidth(r.width());
-        r = inflateRect(r, size, popupButtonMargins(), zoomLevel);
+        r = IntRect(inflateRect(r, size, popupButtonMargins(), zoomLevel));
     }
 }
 
-IntRect RenderThemeMac::inflateRect(const IntRect& r, const IntSize& size, const int* margins, float zoomLevel) const
-{
-    // Only do the inflation if the available width/height are too small.  Otherwise try to
-    // fit the glow/check space into the available box's width/height.
-    int widthDelta = r.width() - (size.width() + margins[leftMargin] * zoomLevel + margins[rightMargin] * zoomLevel);
-    int heightDelta = r.height() - (size.height() + margins[topMargin] * zoomLevel + margins[bottomMargin] * zoomLevel);
-    IntRect result(r);
-    if (widthDelta < 0) {
-        result.setX(result.x() - margins[leftMargin] * zoomLevel);
-        result.setWidth(result.width() - widthDelta);
-    }
-    if (heightDelta < 0) {
-        result.setY(result.y() - margins[topMargin] * zoomLevel);
-        result.setHeight(result.height() - heightDelta);
-    }
-    return result;
-}
-
 FloatRect RenderThemeMac::convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect& r) const
 {
     FloatRect partRect(inputRect);
@@ -899,22 +899,22 @@
     return padding[size];
 }
 
-bool RenderThemeMac::paintMenuList(const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderThemeMac::paintMenuList(const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect)
 {
     LocalCurrentGraphicsContext localContext(paintInfo.context);
-    setPopupButtonCellState(o, r);
+    setPopupButtonCellState(renderer, IntSize(rect.size()));
 
     NSPopUpButtonCell* popupButton = this->popupButton();
 
-    float zoomLevel = o.style().effectiveZoom();
+    float zoomLevel = renderer.style().effectiveZoom();
     IntSize size = popupButtonSizes()[[popupButton controlSize]];
     size.setHeight(size.height() * zoomLevel);
-    size.setWidth(r.width());
+    size.setWidth(rect.width());
 
     // Now inflate it to account for the shadow.
-    IntRect inflatedRect = r;
-    if (r.width() >= minimumMenuListSize(&o.style()))
-        inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel);
+    FloatRect inflatedRect = rect;
+    if (rect.width() >= minimumMenuListSize(&renderer.style()))
+        inflatedRect = inflateRect(rect, size, popupButtonMargins(), zoomLevel);
 
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
 
@@ -929,11 +929,11 @@
         paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y());
     }
 
-    NSView *view = documentViewFor(o);
+    NSView *view = documentViewFor(renderer);
     [popupButton drawWithFrame:inflatedRect inView:view];
-    if (isFocused(o) && o.style().outlineStyleIsAuto()) {
+    if (isFocused(renderer) && renderer.style().outlineStyleIsAuto()) {
         if (wkDrawCellFocusRingWithFrameAtTime(popupButton, inflatedRect, view, std::numeric_limits<double>::max()))
-            o.document().page()->focusController().setFocusedElementNeedsRepaint();
+            renderer.document().page()->focusController().setFocusedElementNeedsRepaint();
     }
 
     [popupButton setControlView:nil];
@@ -1080,7 +1080,7 @@
     // Now inflate it to account for the shadow.
     IntRect inflatedRect = progressBarBounds;
     if (progressBarBounds.height() <= minimumProgressBarHeight(&renderObject.style()))
-        inflatedRect = inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel);
+        inflatedRect = IntRect(inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel));
 
     return inflatedRect;
 }
@@ -1433,12 +1433,12 @@
     style->setLineHeight(RenderStyle::initialLineHeight());
 }
 
-void RenderThemeMac::setPopupButtonCellState(const RenderObject& o, const IntRect& r)
+void RenderThemeMac::setPopupButtonCellState(const RenderObject& o, const IntSize& buttonSize)
 {
     NSPopUpButtonCell* popupButton = this->popupButton();
 
     // Set the control size based off the rectangle we're painting into.
-    setControlSize(popupButton, popupButtonSizes(), r.size(), o.style().effectiveZoom());
+    setControlSize(popupButton, popupButtonSizes(), buttonSize, o.style().effectiveZoom());
 
     // Update the various states we respond to.
     updateCheckedState(popupButton, o);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to