+2012-12-07 Jon Lee <jonlee@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/startButtonPressed@2x.png: Removed.
+ * WebCore.xcodeproj/project.pbxproj:
+
2012-12-07 Scott Violet <sky@chromium.org>
[chromium] Remove linux theme related files and switch to default
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 /* startButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A21655D426000D4645 /* startButton@2x.png */; };
- 31A963A71655D426000D4645 /* startButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A31655D426000D4645 /* startButtonPressed.png */; };
- 31A963A81655D426000D4645 /* startButtonPressed@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A41655D426000D4645 /* startButtonPressed@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 */; };
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 /* startButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "startButton@2x.png"; sourceTree = "<group>"; };
- 31A963A31655D426000D4645 /* startButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = startButtonPressed.png; sourceTree = "<group>"; };
- 31A963A41655D426000D4645 /* startButtonPressed@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "startButtonPressed@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>"; };
85136C960AED665900F90A3D /* southWestResizeCursor.png */,
31A963A11655D426000D4645 /* startButton.png */,
31A963A21655D426000D4645 /* startButton@2x.png */,
- 31A963A31655D426000D4645 /* startButtonPressed.png */,
- 31A963A41655D426000D4645 /* startButtonPressed@2x.png */,
93153BDB141959BB00FCF5BE /* textAreaResizeCorner.png */,
9370918C1416D86B00477333 /* textAreaResizeCorner@2x.png */,
46D4F2480AF97E810035385A /* verticalTextCursor.png */,
1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
31A963A51655D426000D4645 /* startButton.png in Resources */,
31A963A61655D426000D4645 /* startButton@2x.png in Resources */,
- 31A963A71655D426000D4645 /* startButtonPressed.png in Resources */,
- 31A963A81655D426000D4645 /* startButtonPressed@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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);
}
{
if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
paintReplacedSnapshot(paintInfo, paintOffset);
- paintButton(paintInfo, paintOffset);
+ if (m_shouldShowLabel)
+ paintLabel(paintInfo, paintOffset);
return;
}
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()
-{
- static Image* buttonImage = Image::loadPlatformResource("startButtonPressed").leakRef();
- return buttonImage;
-}
-
-void RenderSnapshottedPlugIn::paintButton(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void RenderSnapshottedPlugIn::paintLabel(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) {
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();
}
}
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