- Revision
- 136982
- Author
- jon...@apple.com
- Date
- 2012-12-07 14:08:43 -0800 (Fri, 07 Dec 2012)
Log Message
Display the auto-start label image after a delay
https://bugs.webkit.org/show_bug.cgi?id=104173
<rdar://problem/12820071>
Reviewed by Dan Bernstein.
Treat the button now as a label. Once the user has hovered over the plug-in, wait a little while before showing the label.
* rendering/RenderSnapshottedPlugIn.h:
(RenderSnapshottedPlugIn): Add a one-shot timer, and a variable representing whether the label should
be drawn. Remove the variable that determines whether the label is active.
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Set the time to a delay of 1 second.
(WebCore::RenderSnapshottedPlugIn::paintReplaced): Paint the label only when we should.
(WebCore::RenderSnapshottedPlugIn::paintLabel): The label should only paint in its hovered state.
(WebCore::startLabelImage): Renamed.
(WebCore::RenderSnapshottedPlugIn::repaintLabel): Renamed.
(WebCore::RenderSnapshottedPlugIn::hoverDelayTimerFired): Now that the timer has fired, we should paint
the label. Repaint.
(WebCore::RenderSnapshottedPlugIn::handleEvent): Update event handling. Click event handler is the
same, except we move the label check inside so that if the click is not the left label we don't
fall through to the other irrevelant if clauses.
For the mouse down handler, make sure to check for the left label. If the hover timer is still running,
stop it, so that we don't draw a label while the user is in the middle of a mouse gesture.
Redo mouse over and out. On mouse over we start the delay timer. On mouse out we stop the delay timer
if it is still running, reset state, and paint the label out.
(WebCore::RenderSnapshottedPlugIn::layout): Refactor.
* Resources/startButtonPressed.png: Removed.
* Resources/startbuttonpres...@2x.png: Removed.
* WebCore.xcodeproj/project.pbxproj:
Modified Paths
Removed Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (136981 => 136982)
--- trunk/Source/WebCore/ChangeLog 2012-12-07 22:04:25 UTC (rev 136981)
+++ trunk/Source/WebCore/ChangeLog 2012-12-07 22:08:43 UTC (rev 136982)
@@ -1,3 +1,38 @@
+2012-12-07 Jon Lee <jon...@apple.com>
+
+ Display the auto-start label image after a delay
+ https://bugs.webkit.org/show_bug.cgi?id=104173
+ <rdar://problem/12820071>
+
+ Reviewed by Dan Bernstein.
+
+ Treat the button now as a label. Once the user has hovered over the plug-in, wait a little while before showing the label.
+
+ * rendering/RenderSnapshottedPlugIn.h:
+ (RenderSnapshottedPlugIn): Add a one-shot timer, and a variable representing whether the label should
+ be drawn. Remove the variable that determines whether the label is active.
+
+ * rendering/RenderSnapshottedPlugIn.cpp:
+ (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Set the time to a delay of 1 second.
+ (WebCore::RenderSnapshottedPlugIn::paintReplaced): Paint the label only when we should.
+ (WebCore::RenderSnapshottedPlugIn::paintLabel): The label should only paint in its hovered state.
+ (WebCore::startLabelImage): Renamed.
+ (WebCore::RenderSnapshottedPlugIn::repaintLabel): Renamed.
+ (WebCore::RenderSnapshottedPlugIn::hoverDelayTimerFired): Now that the timer has fired, we should paint
+ the label. Repaint.
+ (WebCore::RenderSnapshottedPlugIn::handleEvent): Update event handling. Click event handler is the
+ same, except we move the label check inside so that if the click is not the left label we don't
+ fall through to the other irrevelant if clauses.
+ For the mouse down handler, make sure to check for the left label. If the hover timer is still running,
+ stop it, so that we don't draw a label while the user is in the middle of a mouse gesture.
+ Redo mouse over and out. On mouse over we start the delay timer. On mouse out we stop the delay timer
+ if it is still running, reset state, and paint the label out.
+ (WebCore::RenderSnapshottedPlugIn::layout): Refactor.
+
+ * Resources/startButtonPressed.png: Removed.
+ * Resources/startbuttonpres...@2x.png: Removed.
+ * WebCore.xcodeproj/project.pbxproj:
+
2012-12-07 Scott Violet <s...@chromium.org>
[chromium] Remove linux theme related files and switch to default
Deleted: trunk/Source/WebCore/Resources/startButtonPressed.png
(Binary files differ)
Deleted: trunk/Source/WebCore/Resources/startbuttonpres...@2x.png
(Binary files differ)
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (136981 => 136982)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-07 22:04:25 UTC (rev 136981)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-07 22:08:43 UTC (rev 136982)
@@ -933,8 +933,6 @@
319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 319FBD5D15D2F444009640A6 /* CachedImageClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
31A963A51655D426000D4645 /* startButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A11655D426000D4645 /* startButton.png */; };
31A963A61655D426000D4645 /* startbut...@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A21655D426000D4645 /* startbut...@2x.png */; };
- 31A963A71655D426000D4645 /* startButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A31655D426000D4645 /* startButtonPressed.png */; };
- 31A963A81655D426000D4645 /* startbuttonpres...@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A41655D426000D4645 /* startbuttonpres...@2x.png */; };
31C0FF210E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */; };
31C0FF220E4CEB6E007D6FE5 /* WebKitAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */; };
31C0FF240E4CEB6E007D6FE5 /* WebKitTransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1E0E4CEB6E007D6FE5 /* WebKitTransitionEvent.cpp */; };
@@ -8131,8 +8129,6 @@
319FBD5D15D2F444009640A6 /* CachedImageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedImageClient.h; sourceTree = "<group>"; };
31A963A11655D426000D4645 /* startButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = startButton.png; sourceTree = "<group>"; };
31A963A21655D426000D4645 /* startbut...@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "startbut...@2x.png"; sourceTree = "<group>"; };
- 31A963A31655D426000D4645 /* startButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = startButtonPressed.png; sourceTree = "<group>"; };
- 31A963A41655D426000D4645 /* startbuttonpres...@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "startbuttonpres...@2x.png"; sourceTree = "<group>"; };
31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitAnimationEvent.cpp; sourceTree = "<group>"; };
31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAnimationEvent.h; sourceTree = "<group>"; };
31C0FF1D0E4CEB6E007D6FE5 /* WebKitAnimationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitAnimationEvent.idl; sourceTree = "<group>"; };
@@ -14541,8 +14537,6 @@
85136C960AED665900F90A3D /* southWestResizeCursor.png */,
31A963A11655D426000D4645 /* startButton.png */,
31A963A21655D426000D4645 /* startbut...@2x.png */,
- 31A963A31655D426000D4645 /* startButtonPressed.png */,
- 31A963A41655D426000D4645 /* startbuttonpres...@2x.png */,
93153BDB141959BB00FCF5BE /* textAreaResizeCorner.png */,
9370918C1416D86B00477333 /* textarearesizecor...@2x.png */,
46D4F2480AF97E810035385A /* verticalTextCursor.png */,
@@ -26055,8 +26049,6 @@
1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
31A963A51655D426000D4645 /* startButton.png in Resources */,
31A963A61655D426000D4645 /* startbut...@2x.png in Resources */,
- 31A963A71655D426000D4645 /* startButtonPressed.png in Resources */,
- 31A963A81655D426000D4645 /* startbuttonpres...@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (136981 => 136982)
--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp 2012-12-07 22:04:25 UTC (rev 136981)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp 2012-12-07 22:08:43 UTC (rev 136982)
@@ -39,12 +39,14 @@
static const int autoStartPlugInSizeThresholdWidth = 1;
static const int autoStartPlugInSizeThresholdHeight = 1;
-static const int startButtonPadding = 10;
+static const int startLabelPadding = 10;
+static const double hoverDelay = 1;
RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element)
: RenderEmbeddedObject(element)
, m_snapshotResource(RenderImageResource::create())
- , m_isMouseInButtonRect(false)
+ , m_shouldShowLabel(false)
+ , m_hoverDelayTimer(this, &RenderSnapshottedPlugIn::hoverDelayTimerFired, hoverDelay)
{
m_snapshotResource->initialize(this);
}
@@ -84,7 +86,8 @@
{
if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
paintReplacedSnapshot(paintInfo, paintOffset);
- paintButton(paintInfo, paintOffset);
+ if (m_shouldShowLabel)
+ paintLabel(paintInfo, paintOffset);
return;
}
@@ -122,41 +125,38 @@
context->drawImage(image.get(), style()->colorSpace(), alignedRect, CompositeSourceOver, shouldRespectImageOrientation(), useLowQualityScaling);
}
-static Image* startButtonImage()
+static Image* startLabelImage()
{
- static Image* buttonImage = Image::loadPlatformResource("startButton").leakRef();
- return buttonImage;
+ static Image* labelImage = Image::loadPlatformResource("startButton").leakRef();
+ return labelImage;
}
-static Image* startButtonPressedImage()
+void RenderSnapshottedPlugIn::paintLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- static Image* buttonImage = Image::loadPlatformResource("startButtonPressed").leakRef();
- return buttonImage;
-}
-
-void RenderSnapshottedPlugIn::paintButton(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
-{
LayoutRect contentRect = contentBoxRect();
if (contentRect.isEmpty())
return;
- Image* buttonImage = startButtonImage();
- if (plugInImageElement()->active()) {
- if (m_isMouseInButtonRect)
- buttonImage = startButtonPressedImage();
- } else if (!plugInImageElement()->hovered())
+ if (!plugInImageElement()->hovered())
return;
- LayoutPoint contentLocation = paintOffset + contentRect.maxXMaxYCorner() - buttonImage->size() - LayoutSize(startButtonPadding, startButtonPadding);
- paintInfo.context->drawImage(buttonImage, ColorSpaceDeviceRGB, roundedIntPoint(contentLocation), buttonImage->rect());
+ Image* labelImage = startLabelImage();
+ LayoutPoint contentLocation = paintOffset + contentRect.maxXMaxYCorner() - labelImage->size() - LayoutSize(startLabelPadding, startLabelPadding);
+ paintInfo.context->drawImage(labelImage, ColorSpaceDeviceRGB, roundedIntPoint(contentLocation), labelImage->rect());
}
-void RenderSnapshottedPlugIn::repaintButton()
+void RenderSnapshottedPlugIn::repaintLabel()
{
- // FIXME: This is unfortunate. We should just repaint the button.
+ // FIXME: This is unfortunate. We should just repaint the label.
repaint();
}
+void RenderSnapshottedPlugIn::hoverDelayTimerFired(DeferrableOneShotTimer<RenderSnapshottedPlugIn>*)
+{
+ m_shouldShowLabel = true;
+ repaintLabel();
+}
+
CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cursor& overrideCursor) const
{
if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
@@ -173,27 +173,36 @@
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
- if (event->type() == eventNames().clickEvent && mouseEvent->button() == LeftButton) {
- if (m_isMouseInButtonRect)
- plugInImageElement()->setDisplayState(HTMLPlugInElement::Playing);
- else {
- plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick);
- plugInImageElement()->setPendingClickEvent(mouseEvent);
- }
+ if (event->type() == eventNames().clickEvent) {
+ if (mouseEvent->button() != LeftButton)
+ return;
+
+ plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick);
+ plugInImageElement()->setPendingClickEvent(mouseEvent);
+
if (widget()) {
if (Frame* frame = document()->frame())
frame->loader()->client()->recreatePlugin(widget());
repaint();
}
event->setDefaultHandled();
- } else if (event->type() == eventNames().mouseoverEvent || event->type() == eventNames().mouseoutEvent)
- repaintButton();
- else if (event->type() == eventNames().mousedownEvent) {
- bool isMouseInButtonRect = m_buttonRect.contains(IntPoint(mouseEvent->offsetX(), mouseEvent->offsetY()));
- if (isMouseInButtonRect != m_isMouseInButtonRect) {
- m_isMouseInButtonRect = isMouseInButtonRect;
- repaintButton();
- }
+ } else if (event->type() == eventNames().mousedownEvent) {
+ if (mouseEvent->button() != LeftButton)
+ return;
+
+ if (m_hoverDelayTimer.isActive())
+ m_hoverDelayTimer.stop();
+
+ event->setDefaultHandled();
+ } else if (event->type() == eventNames().mouseoverEvent) {
+ m_hoverDelayTimer.restart();
+ event->setDefaultHandled();
+ } else if (event->type() == eventNames().mouseoutEvent) {
+ if (m_hoverDelayTimer.isActive())
+ m_hoverDelayTimer.stop();
+ m_shouldShowLabel = false;
+ repaintLabel();
+ event->setDefaultHandled();
}
}
@@ -208,8 +217,8 @@
plugInImageElement()->setDisplayState(HTMLPlugInElement::Playing);
}
- LayoutSize buttonSize = startButtonImage()->size();
- m_buttonRect = LayoutRect(contentBoxRect().maxXMaxYCorner() - LayoutSize(startButtonPadding, startButtonPadding) - buttonSize, buttonSize);
+ LayoutSize labelSize = startLabelImage()->size();
+ m_labelRect = LayoutRect(contentBoxRect().maxXMaxYCorner() - LayoutSize(startLabelPadding, startLabelPadding) - labelSize, labelSize);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h (136981 => 136982)
--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h 2012-12-07 22:04:25 UTC (rev 136981)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h 2012-12-07 22:08:43 UTC (rev 136982)
@@ -30,6 +30,7 @@
#include "RenderImageResource.h"
#include "RenderTheme.h"
+#include "Timer.h"
namespace WebCore {
@@ -43,6 +44,7 @@
void updateSnapshot(PassRefPtr<Image>);
void handleEvent(Event*);
+ void hoverDelayTimerFired(DeferrableOneShotTimer<RenderSnapshottedPlugIn>*);
private:
HTMLPlugInImageElement* plugInImageElement() const;
@@ -54,14 +56,15 @@
virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
void paintReplacedSnapshot(PaintInfo&, const LayoutPoint&);
- void paintButton(PaintInfo&, const LayoutPoint&);
- void repaintButton();
+ void paintLabel(PaintInfo&, const LayoutPoint&);
+ void repaintLabel();
virtual void layout() OVERRIDE;
OwnPtr<RenderImageResource> m_snapshotResource;
- LayoutRect m_buttonRect;
- bool m_isMouseInButtonRect;
+ LayoutRect m_labelRect;
+ bool m_shouldShowLabel;
+ DeferrableOneShotTimer<RenderSnapshottedPlugIn> m_hoverDelayTimer;
};
inline RenderSnapshottedPlugIn* toRenderSnapshottedPlugIn(RenderObject* object)