Title: [112643] branches/safari-534.56-branch/Source/WebCore
Revision
112643
Author
[email protected]
Date
2012-03-29 21:43:59 -0700 (Thu, 29 Mar 2012)

Log Message

<rdar://problem/11008998> Branch: Shadow inside text field is blurry/blocky in 
HiDPI

Reviewed by Dan Bernstein.

This patch merges the following changes to the branch:
http://trac.webkit.org/changeset/97032
http://trac.webkit.org/changeset/98520

This patch also adds branch-specific code that makes it so the regression tracked 
by <rdar://problem/11115221> only affects the branch in HiDPI mode.

Essentially, this is a workaround for <rdar://problem/11150452>. With this 
workaround, when the deviceScaleFactor is 1, we have an old-school gradient bezel 
in text fields whether they are styled or not. This is good and matches shipping 
Safari. When the deviceScaleFactor is greater than 1, text fields will have newer, 
AppKit-matching gradients that look much more appropriate at the higher 
resolutions. However, if the text field is styled  in any way, we'll revert to the 
old-school bezel, which doesn't look great in HiDPI, but it looks better than the 
CSS border, which is the only alternative until 11150452 is resolved.

This is the merging of the changes listed above. 
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::ensuredView):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintSliderThumb):

isControlStyled() should treat text fields like it used to in order to avoid the 
regression tracked by 11115221.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::isControlStyled):

Use the old gradient always unless we are an unstyled text field in HiDPI.
(WebCore::RenderThemeMac::paintTextField):
(WebCore::RenderThemeMac::textField):

Modified Paths

Diff

Modified: branches/safari-534.56-branch/Source/WebCore/ChangeLog (112642 => 112643)


--- branches/safari-534.56-branch/Source/WebCore/ChangeLog	2012-03-30 03:44:14 UTC (rev 112642)
+++ branches/safari-534.56-branch/Source/WebCore/ChangeLog	2012-03-30 04:43:59 UTC (rev 112643)
@@ -1,3 +1,42 @@
+2012-03-29  Beth Dakin  <[email protected]>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/11008998> Branch: Shadow inside text field is blurry/blocky in 
+        HiDPI
+
+        This patch merges the following changes to the branch:
+        http://trac.webkit.org/changeset/97032
+        http://trac.webkit.org/changeset/98520
+
+        This patch also adds branch-specific code that makes it so the regression tracked 
+        by <rdar://problem/11115221> only affects the branch in HiDPI mode.
+
+        Essentially, this is a workaround for <rdar://problem/11150452>. With this 
+        workaround, when the deviceScaleFactor is 1, we have an old-school gradient bezel 
+        in text fields whether they are styled or not. This is good and matches shipping 
+        Safari. When the deviceScaleFactor is greater than 1, text fields will have newer, 
+        AppKit-matching gradients that look much more appropriate at the higher 
+        resolutions. However, if the text field is styled  in any way, we'll revert to the 
+        old-school bezel, which doesn't look great in HiDPI, but it looks better than the 
+        CSS border, which is the only alternative until 11150452 is resolved.
+
+        This is the merging of the changes listed above. 
+        * platform/mac/ThemeMac.mm:
+        (WebCore::ThemeMac::ensuredView):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintSliderThumb):
+
+        isControlStyled() should treat text fields like it used to in order to avoid the 
+        regression tracked by 11115221.
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::isControlStyled):
+
+        Use the old gradient always unless we are an unstyled text field in HiDPI.
+        (WebCore::RenderThemeMac::paintTextField):
+        (WebCore::RenderThemeMac::textField):
+
 2012-03-16  Lucas Forschler  <[email protected]>
 
     Merge 107102

Modified: branches/safari-534.56-branch/Source/WebCore/platform/mac/ThemeMac.mm (112642 => 112643)


--- branches/safari-534.56-branch/Source/WebCore/platform/mac/ThemeMac.mm	2012-03-30 03:44:14 UTC (rev 112642)
+++ branches/safari-534.56-branch/Source/WebCore/platform/mac/ThemeMac.mm	2012-03-30 04:43:59 UTC (rev 112643)
@@ -37,7 +37,7 @@
 using namespace std;
 
 // This is a view whose sole purpose is to tell AppKit that it's flipped.
-@interface WebCoreFlippedView : NSView
+@interface WebCoreFlippedView : NSControl
 @end
 
 @implementation WebCoreFlippedView
@@ -556,6 +556,7 @@
     
     // Use a fake flipped view.
     static NSView *flippedView = [[WebCoreFlippedView alloc] init];
+    [flippedView setFrameSize:scrollView->contentsSize()];
     
     return flippedView;
 }

Modified: branches/safari-534.56-branch/Source/WebCore/rendering/RenderThemeMac.h (112642 => 112643)


--- branches/safari-534.56-branch/Source/WebCore/rendering/RenderThemeMac.h	2012-03-30 03:44:14 UTC (rev 112642)
+++ branches/safari-534.56-branch/Source/WebCore/rendering/RenderThemeMac.h	2012-03-30 04:43:59 UTC (rev 112643)
@@ -218,7 +218,7 @@
     NSMenu* searchMenuTemplate() const;
     NSSliderCell* sliderThumbHorizontal() const;
     NSSliderCell* sliderThumbVertical() const;
-    NSTextFieldCell* textField() const;
+    NSTextFieldCell* textField(bool useNewGradient) const;
 
 #if ENABLE(METER_TAG)
     NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const;

Modified: branches/safari-534.56-branch/Source/WebCore/rendering/RenderThemeMac.mm (112642 => 112643)


--- branches/safari-534.56-branch/Source/WebCore/rendering/RenderThemeMac.mm	2012-03-30 03:44:14 UTC (rev 112642)
+++ branches/safari-534.56-branch/Source/WebCore/rendering/RenderThemeMac.mm	2012-03-30 04:43:59 UTC (rev 112643)
@@ -35,6 +35,7 @@
 #import "ImageBuffer.h"
 #import "LocalCurrentGraphicsContext.h"
 #import "MediaControlElements.h"
+#import "Page.h"
 #import "PaintInfo.h"
 #import "RenderMedia.h"
 #import "RenderMediaControls.h"
@@ -481,7 +482,7 @@
 bool RenderThemeMac::isControlStyled(const RenderStyle* style, const BorderData& border,
                                      const FillLayer& background, const Color& backgroundColor) const
 {
-    if (style->appearance() == TextAreaPart || style->appearance() == ListboxPart)
+    if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart || style->appearance() == ListboxPart)
         return style->border() != border;
         
     // FIXME: This is horrible, but there is not much else that can be done.  Menu lists cannot draw properly when
@@ -707,8 +708,20 @@
 bool RenderThemeMac::paintTextField(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
     LocalCurrentGraphicsContext localContext(paintInfo.context);
-    NSTextFieldCell* textField = this->textField();
 
+    // See comment in RenderThemeMac::textField() for a complete explanation of this. In short,
+    // we only want to use the new style gradient for completely unstyled text fields in HiDPI. 
+    // isControledStyle(), however, treats all text fields that do not have custom borders as
+    // "unstyled" to avoid using the CSS border in that case, so we have to sniff around for 
+    // other types of styling.
+    bool useNewGradient = WebCore::deviceScaleFactor(o->frame()) != 1;
+    if (useNewGradient) {
+        useNewGradient = o->style()->hasAppearance() 
+            && o->style()->visitedDependentColor(CSSPropertyBackgroundColor) == Color::white
+            && !o->style()->hasBackgroundImage();
+    }
+    NSTextFieldCell* textField = this->textField(useNewGradient);
+
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
 
     [textField setEnabled:(isEnabled(o) && !isReadOnlyControl(o))];
@@ -1357,15 +1370,6 @@
         paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
     }
     
-#if PLATFORM(MAC)
-    // Workaround for <rdar://problem/9421781>.
-    if (!o->view()->frameView()->documentView()) {
-        paintInfo.context->translate(0, unzoomedRect.y());
-        paintInfo.context->scale(FloatSize(1, -1));
-        paintInfo.context->translate(0, -(unzoomedRect.y() + unzoomedRect.height()));
-    }
-#endif
-    
     [sliderThumbCell drawInteriorWithFrame:unzoomedRect inView:documentViewFor(o)];
     [sliderThumbCell setControlView:nil];
 
@@ -2043,15 +2047,27 @@
     return m_sliderThumbVertical.get();
 }
 
-NSTextFieldCell* RenderThemeMac::textField() const
+NSTextFieldCell* RenderThemeMac::textField(bool useNewGradient) const
 {
     if (!m_textField) {
         m_textField.adoptNS([[NSTextFieldCell alloc] initTextCell:@""]);
         [m_textField.get() setBezeled:YES];
         [m_textField.get() setEditable:YES];
         [m_textField.get() setFocusRingType:NSFocusRingTypeExterior];
+        [m_textField.get() setDrawsBackground:YES];
     }
 
+    // This is a workaround for <rdar://problem/11150452>. With this workaround, when the deviceScaleFactor is 1,
+    // we have an old-school gradient bezel in text fields whether they are styled or not. This is good and 
+    // matches shipping Safari. When the deviceScaleFactor is greater than 1, text fields will have newer, 
+    // AppKit-matching gradients that look much more appropriate at the higher resolutions. However, if the text 
+    // field is styled  in any way, we'll revert to the old-school bezel, which doesn't look great in HiDPI, but 
+    // it looks better than the CSS border, which is the only alternative until 11150452 is resolved.
+    if (useNewGradient)
+        [m_textField.get() setBackgroundColor:[NSColor whiteColor]]; 
+    else
+        [m_textField.get() setBackgroundColor:[NSColor clearColor]];
+
     return m_textField.get();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to