Event's relatedTarget re-targeting does not occur for manually fired mouse events created by event.initMouseEvent().
https://bugs.webkit.org/show_bug.cgi?id=102681

Reviewed by Dimitri Glazkov.

Source/WebCore:

Make sure that event's relatedTarget re-targeting occurs for mouse
events created by event.initMouseEvent().  Since user-generated
mouse events can have a relatedTarget which is same to the target
node, the algorithm which calculates event's ancestors is also
updated so that ancestors are not shrunk wrongly.

Test: fast/events/dispatch-synthetic-mouseevent.html
      fast/dom/shadow/shadow-dom-event-dispatching.html

* dom/EventDispatcher.cpp:
(WebCore::EventRelatedTargetAdjuster::adjust):
* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::create):
(WebCore::MouseEventDispatchMediator::MouseEventDispatchMediator):
(WebCore::MouseEventDispatchMediator::dispatchEvent):
* dom/MouseEvent.h:
(WebCore::MouseEventDispatchMediator::isSyntheticMouseEvent):
(MouseEventDispatchMediator):
* dom/Node.cpp:
(WebCore::Node::dispatchEvent):

LayoutTests:

* fast/dom/shadow/shadow-dom-event-dispatching-expected.txt:
* fast/dom/shadow/shadow-dom-event-dispatching.html:
* fast/events/dispatch-synthetic-mouseevent-expected.txt: Added.
* fast/events/dispatch-synthetic-mouseevent.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136918 268f45cc-cd09-0410-ab3c-d52691b4dbfc
CSS cursor property should support webkit-image-set
https://bugs.webkit.org/show_bug.cgi?id=99493

Patch by Rick Byers <rbyers@chromium.org> on 2012-12-06
Reviewed by Beth Dakin.

.:

Add ENABLE_MOUSE_CURSOR_SCALE (disabled by default)

* Source/cmake/WebKitFeatures.cmake:
* Source/cmakeconfig.h.cmake:

Source/JavaScriptCore:

Add ENABLE_MOUSE_CURSOR_SCALE (disabled by default)

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

Add support for image scale factors attached to custom mouse cursor images
behind ENABLE(MOUSE_CURSOR_SCALE).

This required refactoring CSSCursorImageValue to derive directly from
CSSValue since it can contain either a CSSImageValue or a CSSImageSetValue.
If it contains an image-set, then we can plumb directly through to the
CSSImageSetValue.  If it contains an image, then either we can plumb directly
through to the CSSImageValue, or if the URL represents an SVG cursor we have
to intercept the image loading in order to substitute the actual SVG image URL
and do the appropriate lifetime management.

Tests: fast/css/cursor-parsing-image-set.html
       fast/events/mouse-cursor-image-set.html

* Configurations/FeatureDefines.xcconfig: Add ENABLE_MOUSE_CURSOR_SCALE - disabled
* GNUmakefile.features.am: ditto
* css/CSSCursorImageValue.cpp: Refactor to inherit directly from CSSValue and support image sets
(WebCore::CSSCursorImageValue::CSSCursorImageValue):
(WebCore::CSSCursorImageValue::~CSSCursorImageValue):
(WebCore::CSSCursorImageValue::customCssText):
(WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
(WebCore::CSSCursorImageValue::cachedImage):
(WebCore::CSSCursorImageValue::cachedOrPendingImage):
(WebCore::CSSCursorImageValue::isSVGCursor):
(WebCore::CSSCursorImageValue::cachedImageURL):
(WebCore::CSSCursorImageValue::clearCachedImage):
(WebCore::CSSCursorImageValue::reportDescendantMemoryUsage):
* css/CSSCursorImageValue.h: Remove cursor-specific hacks
(WebCore::CSSCursorImageValue::create):
(CSSCursorImageValue):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* css/CSSImageValue.h:
(CSSImageValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Parse cursor(-webkit-image-set(...)) rules
* css/CSSValue.h:
(WebCore::CSSValue::isImageValue):
* css/StyleBuilder.cpp:
(WebCore::ApplyPropertyCursor::applyValue):
* css/StyleResolver.cpp: Hook up new CSSCursorImageValue support since it can't be handled like other images any more.
(WebCore::StyleResolver::styleImage):
(WebCore::StyleResolver::cursorOrPendingFromValue):
(WebCore::StyleResolver::loadPendingImage):
* css/StyleResolver.h:
(StyleResolver):
* page/EventHandler.cpp:
(WebCore::EventHandler::selectCursor): Handle StyleCachedImageSet images and plumb scale factor through
* platform/Cursor.cpp:
(WebCore::Cursor::Cursor): Add imageScaleFactor
* platform/Cursor.h: Add imageScaleFactor
(Cursor):
(WebCore::Cursor::imageScaleFactor):
* platform/chromium/CursorChromium.cpp: Add imageScaleFactor
(WebCore::Cursor::Cursor):
(WebCore::Cursor::operator=):
* rendering/style/CursorData.h: Clarify hotspot units
(CursorData):
* rendering/style/StyleCachedImage.h:
(StyleCachedImage::cachedImage): Override new virtual.
* rendering/style/StyleCachedImageSet.h:
(StyleCachedImageSet::cachedImage): Override new virtual.
* rendering/style/StyleImage.h:
(StyleImage::cachedImage): Add new virtual method to avoid lots of casts and typechecks.
* rendering/style/StylePendingImage.h: Add CSSCursorImageValue support
(WebCore::StylePendingImage::cssCursorImageValue):
* testing/Internals.cpp:
(WebCore::Internals::getCurrentCursorInfo): Print non-identity scale factors for testing

Source/WebKit/chromium:

Add ENABLE_MOUSE_CURSOR_SCALE and enable it on the chromium port.
Plumb cursor image scale factor through to chromium API.

* features.gypi:
* public/WebCursorInfo.h:
* src/WebCursorInfo.cpp:
(WebKit::WebCursorInfo::WebCursorInfo):

Source/WebKit/mac:

Add ENABLE_MOUSE_CURSOR_SCALE - disabled by default.

* Configurations/FeatureDefines.xcconfig:

Source/WebKit2:

Add ENABLE_MOUSE_CURSOR_SCALE - disabled by default.

* Configurations/FeatureDefines.xcconfig:

Tools:

Add ENABLE_MOUSE_CURSOR_SCALE - disabled by default

* Scripts/webkitperl/FeatureList.pm:
* qmake/mkspecs/features/features.pri:

WebKitLibraries:

Add ENABLE_MOUSE_CURSOR_SCALE - disabled by default

* win/tools/vsprops/FeatureDefines.vsprops:
* win/tools/vsprops/FeatureDefinesCairo.vsprops:

LayoutTests:

Add tests for parser round-tripping of cursor rules with -webkit-image-set,
and also end-to-end mouse cursor tests that validate the cursor details
ultimately used at different device scales.

Tests are disabled on ports other than chromium (require ENABLE(MOUSE_CURSOR_SCALE))

* fast/css/cursor-parsing-image-set-expected.txt: Added.
* fast/css/cursor-parsing-image-set.html: Added.
* fast/events/mouse-cursor-image-set-expected.txt: Added.
* fast/events/mouse-cursor-image-set.html: Added.
* fast/events/resources/greenbox200.png: Added.
* fast/events/resources/greenbox30-hotspot28-3.cur: Added.
* fast/events/resources/greenbox30.png: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/win/TestExpectations:

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