+2014-12-22 Timothy Horton <timothy_horton@apple.com>
+
+ TextIndicatorWindow is larger than it needs to be, especially when not bouncing
+ https://bugs.webkit.org/show_bug.cgi?id=139876
+ <rdar://problem/19311017>
+
+ Reviewed by Sam Weinig.
+
+ * page/TextIndicator.cpp:
+ (WebCore::TextIndicator::wantsBounce):
+ (WebCore::TextIndicator::wantsContentCrossfade):
+ (WebCore::TextIndicator::wantsFadeIn):
+ * page/TextIndicator.h:
+ * page/mac/TextIndicatorWindow.mm:
+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:]):
+ (-[WebTextIndicatorView _animationDuration]):
+ (-[WebTextIndicatorView present]):
+ (WebCore::TextIndicatorWindow::setTextIndicator):
+ (-[WebTextIndicatorView _textIndicatorWantsBounce]): Deleted.
+ (-[WebTextIndicatorView _textIndicatorWantsContentCrossfade]): Deleted.
+ (-[WebTextIndicatorView _textIndicatorWantsFadeIn]): Deleted.
+ Move the various switches over TextIndicatorPresentationTransition into TextIndicator.
+ Adjust the margin; only inflate by the shadow if we're not bouncing.
+ If we are bouncing, fix the math to more tightly fit the bounce.
+ Previously we were inflating by way too much, and even when we didn't need to.
+
2014-12-22 Chris Dumez <cdumez@apple.com>
[iOS] Log using FeatureCounter when a PacheCache entry is not reused because it expired
TextIndicator::~TextIndicator()
{
}
+
+bool TextIndicator::wantsBounce() const
+{
+ switch (m_data.presentationTransition) {
+ case TextIndicatorPresentationTransition::BounceAndCrossfade:
+ case TextIndicatorPresentationTransition::Bounce:
+ return true;
+
+ case TextIndicatorPresentationTransition::FadeIn:
+ case TextIndicatorPresentationTransition::Crossfade:
+ case TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ return false;
+}
+
+bool TextIndicator::wantsContentCrossfade() const
+{
+ if (!m_data.contentImageWithHighlight)
+ return false;
+
+ switch (m_data.presentationTransition) {
+ case TextIndicatorPresentationTransition::BounceAndCrossfade:
+ case TextIndicatorPresentationTransition::Crossfade:
+ return true;
+
+ case TextIndicatorPresentationTransition::Bounce:
+ case TextIndicatorPresentationTransition::FadeIn:
+ case TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ return false;
+}
+
+bool TextIndicator::wantsFadeIn() const
+{
+ switch (m_data.presentationTransition) {
+ case TextIndicatorPresentationTransition::FadeIn:
+ return true;
+
+ case TextIndicatorPresentationTransition::Bounce:
+ case TextIndicatorPresentationTransition::BounceAndCrossfade:
+ case TextIndicatorPresentationTransition::Crossfade:
+ case TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ return false;
+}
} // namespace WebCore
self.wantsLayer = YES;
self.layer.anchorPoint = CGPointZero;
- bool wantsCrossfade = [self _textIndicatorWantsContentCrossfade];
+ bool wantsCrossfade = _textIndicator->wantsContentCrossfade();
FloatSize contentsImageLogicalSize = _textIndicator->contentImage()->size();
contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
return fadeInAnimation;
}
-- (bool)_textIndicatorWantsBounce
-{
- switch (_textIndicator->presentationTransition()) {
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- case TextIndicatorPresentationTransition::Bounce:
- return true;
-
- case TextIndicatorPresentationTransition::FadeIn:
- case TextIndicatorPresentationTransition::Crossfade:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- return false;
-}
-
-- (bool)_textIndicatorWantsContentCrossfade
-{
- if (!_textIndicator->contentImageWithHighlight())
- return false;
-
- switch (_textIndicator->presentationTransition()) {
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- case TextIndicatorPresentationTransition::Crossfade:
- return true;
-
- case TextIndicatorPresentationTransition::Bounce:
- case TextIndicatorPresentationTransition::FadeIn:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- return false;
-}
-
-- (bool)_textIndicatorWantsFadeIn
-{
- switch (_textIndicator->presentationTransition()) {
- case TextIndicatorPresentationTransition::FadeIn:
- return true;
-
- case TextIndicatorPresentationTransition::Bounce:
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- case TextIndicatorPresentationTransition::Crossfade:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- return false;
-}
-
- (CFTimeInterval)_animationDuration
{
- bool wantsBounce = [self _textIndicatorWantsBounce];
- bool wantsCrossfade = [self _textIndicatorWantsContentCrossfade];
-
- if (wantsBounce) {
- if (wantsCrossfade)
+ if (_textIndicator->wantsBounce()) {
+ if (_textIndicator->wantsContentCrossfade())
return bounceWithCrossfadeAnimationDuration;
return bounceAnimationDuration;
}
- (void)present
{
- bool wantsBounce = [self _textIndicatorWantsBounce];
- bool wantsCrossfade = [self _textIndicatorWantsContentCrossfade];
- bool wantsFadeIn = [self _textIndicatorWantsFadeIn];
+ bool wantsBounce = _textIndicator->wantsBounce();
+ bool wantsCrossfade = _textIndicator->wantsContentCrossfade();
+ bool wantsFadeIn = _textIndicator->wantsFadeIn();
CFTimeInterval animationDuration = [self _animationDuration];
_hasCompletedAnimation = false;
if (!m_textIndicator)
return;
- CGFloat horizontalMargin = std::max(dropShadowBlurRadius * 2 + horizontalBorder, contentRect.size.width * 2);
- CGFloat verticalMargin = std::max(dropShadowBlurRadius * 2 + verticalBorder, contentRect.size.height * 2);
+ CGFloat horizontalMargin = dropShadowBlurRadius * 2 + horizontalBorder;
+ CGFloat verticalMargin = dropShadowBlurRadius * 2 + verticalBorder;
+
+ if (m_textIndicator->wantsBounce()) {
+ horizontalMargin = std::max(horizontalMargin, contentRect.size.width * (midBounceScale - 1) + horizontalMargin);
+ verticalMargin = std::max(verticalMargin, contentRect.size.height * (midBounceScale - 1) + verticalMargin);
+ }
contentRect = CGRectInset(contentRect, -horizontalMargin, -verticalMargin);
NSRect windowContentRect = [NSWindow contentRectForFrameRect:NSIntegralRect(NSRectFromCGRect(contentRect)) styleMask:NSBorderlessWindowMask];