Default buttons do not pulse in OS X 10.10
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jul 2014 22:07:46 +0000 (22:07 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jul 2014 22:07:46 +0000 (22:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135447
<rdar://problem/17875896>

Reviewed by Dan Bernstein.

OS X Yosemite does not have the animated pulsing default
buttons seen in previous releases. We don't need to have
a timer in RenderButton constantly triggering repaints.

* platform/mac/ThemeMac.mm:
(WebCore::paintButton): No need to advance the animation.
* rendering/RenderButton.cpp:
(WebCore::RenderButton::styleDidChange): Ask the theme if it
should advance the animation.
* rendering/RenderTheme.h:
(WebCore::RenderTheme::defaultButtonHasAnimation): Virtual function
indicating if the button needs to repaint.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::defaultButtonHasAnimation): Provide platform
specific result on Yosemite and above.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/rendering/RenderButton.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm

index c691e35..d7926c6 100644 (file)
@@ -1,3 +1,28 @@
+2014-07-31  Dean Jackson  <dino@apple.com>
+
+        Default buttons do not pulse in OS X 10.10
+        https://bugs.webkit.org/show_bug.cgi?id=135447
+        <rdar://problem/17875896>
+
+        Reviewed by Dan Bernstein.
+
+        OS X Yosemite does not have the animated pulsing default
+        buttons seen in previous releases. We don't need to have
+        a timer in RenderButton constantly triggering repaints.
+
+        * platform/mac/ThemeMac.mm:
+        (WebCore::paintButton): No need to advance the animation.
+        * rendering/RenderButton.cpp:
+        (WebCore::RenderButton::styleDidChange): Ask the theme if it
+        should advance the animation.
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::defaultButtonHasAnimation): Virtual function
+        indicating if the button needs to repaint.
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::defaultButtonHasAnimation): Provide platform
+        specific result on Yosemite and above.
+
 2014-07-31  Tim Horton  <timothy_horton@apple.com>
 
         DOM::renderedImageForcingBlackText returns an image with the wrong logical size on 2x displays
index 2d5711f..e8f832c 100644 (file)
@@ -563,7 +563,9 @@ static void paintButton(ControlPart part, ControlStates* controlStates, Graphics
 
     if (states & ControlStates::DefaultState) {
         [window setDefaultButtonCell:buttonCell];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
         wkAdvanceDefaultButtonPulseAnimation(buttonCell);
+#endif
     } else if ([previousDefaultButtonCell isEqual:buttonCell])
         [window setDefaultButtonCell:nil];
 
index e067884..f4dacfa 100644 (file)
@@ -114,9 +114,11 @@ void RenderButton::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
         setupInnerStyle(&m_inner->style());
 
     if (!m_default && theme().isDefault(*this)) {
-        if (!m_timer)
-            m_timer = std::make_unique<Timer<RenderButton>>(this, &RenderButton::timerFired);
-        m_timer->startRepeating(0.03);
+        if (theme().defaultButtonHasAnimation()) {
+            if (!m_timer)
+                m_timer = std::make_unique<Timer<RenderButton>>(this, &RenderButton::timerFired);
+            m_timer->startRepeating(0.03);
+        }
         m_default = true;
     } else if (m_default && !theme().isDefault(*this)) {
         m_default = false;
index c9d84a4..246ed0a 100644 (file)
@@ -249,6 +249,8 @@ public:
     virtual IntSize imageControlsButtonPositionOffset() const { return IntSize(); }
 #endif
 
+    virtual bool defaultButtonHasAnimation() const { return false; }
+
 protected:
     // The platform selection color.
     virtual Color platformActiveSelectionBackgroundColor() const;
index 2b83d40..2522a27 100644 (file)
@@ -106,6 +106,8 @@ public:
     // A view associated to the contained document.
     NSView* documentViewFor(const RenderObject&) const;
 
+    virtual bool defaultButtonHasAnimation() const override;
+
 protected:
     RenderThemeMac();
     virtual ~RenderThemeMac();
index a4c686d..c800887 100644 (file)
@@ -2024,6 +2024,15 @@ String RenderThemeMac::fileListNameForWidth(const FileList* fileList, const Font
     return StringTruncator::centerTruncate(strToTruncate, width, font, StringTruncator::EnableRoundingHacks);
 }
 
+bool RenderThemeMac::defaultButtonHasAnimation() const
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+    return false;
+#else
+    return true;
+#endif
+}
+
 #if ENABLE(SERVICE_CONTROLS)
 NSServicesRolloverButtonCell* RenderThemeMac::servicesRolloverButtonCell() const
 {