[Qt][Win] Input events aren't mapped properly with windowless plugins.

https://bugs.webkit.org/show_bug.cgi?id=116094
Reviewed by Tor Arne Vestbø.

Source/WebCore:

The events are first sent properly but Flash then immediately repaints
and this causes flickering painting.
The issue is that Flash seems to be doing some input event tracking of
its own internally, using the HWND returned through NPN_GetValue(NPNVnetscapeWindow).

We are currently using two coordinate systems for windowless plugins on Windows with Qt:
- FrameView coordinates: Used for input events and ajusted with the WM_WINDOWPOSCHANGED message
- Drawable coordinates: Used by WM_PAINT and adjusted with NPP_SetWindow

This patch fixes the bug by mapping input events to the native window returned
as NPNVnetscapeWindow instead of the FrameView to ensure that those coordinates will match
the ones used by Flash internally.
With this we shouldn't be using FrameView coordinates anywhere for windowless plugins
on Windows with Qt.

* platform/qt/QWebPageClient.h:
(QWebPageClient):
  Added mapToOwnerWindow to the interface, mapping from the FrameView up to the wrapping nativeParentWidget.
* plugins/win/PluginViewWin.cpp:
(WebCore::contentsToNativeWindow):
(WebCore::PluginView::paintIntoTransformedContext):
(WebCore::PluginView::handleMouseEvent):

Source/WebKit/qt:

* WidgetSupport/PageClientQt.cpp:
(WebCore::PageClientQWidget::mapToOwnerWindow):
(WebCore::PageClientQGraphicsWidget::makeOpenGLContextCurrentIfAvailable):
(WebCore::PageClientQGraphicsWidget::screenNumber):
(WebCore::PageClientQGraphicsWidget::geometryRelativeToOwnerWidget):
(WebCore::PageClientQGraphicsWidget::mapToOwnerWindow):
(WebCore::PageClientQGraphicsWidget::graphicsItemVisibleRect):
(WebCore::PageClientQGraphicsWidget::firstGraphicsView):
  Extracted this common logic from makeOpenGLContextCurrentIfAvailable,
  screenNumber, geometryRelativeToOwnerWidget and graphicsItemVisibleRect
  to be able to use it in mapToOwnerWindow.
* WidgetSupport/PageClientQt.h:
(PageClientQWidget):
(PageClientQGraphicsWidget):

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

Conflicts:
	Source/WebCore/plugins/win/PluginViewWin.cpp

Change-Id: I11ec6b6a9377c3e09b775d24fffb8572decbd0a5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] Fix a crash in QtPixmapRuntime.

https://bugs.webkit.org/show_bug.cgi?id=117193
Reviewed by Allan Sandfeld Jensen.

The crash could only be reproduced in release builds on Windows.
JSClassCreate calculates the size of JSClassDefinition.staticValues
and staticFunctions by iterating until an entry with a null name is found.

* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::QtPixmapRuntime::getClassRef):

Task-number: QTBUG-30736
Change-Id: I443c69fd6772b78edbdadb6270c30229b30d992d
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151170 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Make PNGImageDecoder::rowAvailable auto-vectorizable

https://bugs.webkit.org/show_bug.cgi?id=116151

Reviewed by Benjamin Poulain.

Changed the main loops under PNGImageDecoder::rowAvailable so that they
avoid branches and non-sequential table look ups.

Together with automatic vectorization by the compiler this provides around
4x speed-up with AVX or 2x speed-up on generic x64. Shaving off 12-40% on
PNG decoding in general.

* platform/graphics/Color.cpp:
(WebCore::premultipliedARGBFromColor):
* platform/graphics/Color.h:
(WebCore::fastDivideBy255):
* platform/graphics/filters/FEBlend.cpp:
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::setPixelRGB):
(WebCore::setPixelRGBA):
(WebCore::setPixelRGBA_Premultiplied):
(WebCore::PNGImageDecoder::rowAvailable):

Change-Id: Ic3d6cefda505ebceb37165d0a7aeb3cd2fe3e2c9
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150252 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Crash when loading link to audio file

https://bugs.webkit.org/show_bug.cgi?id=115794

Reviewed by Jocelyn Turcotte.

Do not access a null pointer frame.

* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::isApplicationCacheEnabled):

Change-Id: I1c7c8ea84394f669e565634f71720ae504ceded4
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
[Qt][Mac] Remove Carbon and QuickDraw support for plugins.

https://bugs.webkit.org/show_bug.cgi?id=116619
Reviewed by Tor Arne Vestbø.

They are only enabled for 32bit builds of QtWebKit and are rarely tested.
Other browsers support them through a 32bit host process.
PluginViewMac.mm is only used by Qt since the Wx port was removed.

- Only support the Cocoa event model
- Only support the CoreGraphics drawing model
- Remove all NP_NO_CARBON and NP_NO_QUICKDRAW blocks in PluginViewMac.mm

* plugins/PluginView.cpp:
(WebCore::PluginView::setValue):
(WebCore::PluginView::PluginView):
* plugins/PluginView.h:
* plugins/mac/PluginViewMac.mm:
(WebCore::PluginView::platformStart):
(WebCore::PluginView::platformDestroy):
(WebCore::PluginView::platformGetValueStatic):
(WebCore::PluginView::setFocus):
(WebCore::PluginView::setNPWindowIfNeeded):
(WebCore::PluginView::paint):
(WebCore::PluginView::handleWheelEvent):
(WebCore::PluginView::handleMouseEvent):
(WebCore::PluginView::handleKeyboardEvent):

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

Conflicts:
	Source/WebCore/plugins/mac/PluginViewMac.mm

Change-Id: Id4939dfe00a306299ab54c28b03f949ce4beb4d8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt][Mac] Allow drawing plugins with QWindow by always using an intermediate bitmap.

https://bugs.webkit.org/show_bug.cgi?id=116620
Reviewed by Tor Arne Vestbø.

The isolation of QWidget along with QPA in Qt5 is abstracting away the native CGContext
of a QWidget and we would need to create a non-public API to be able to achieve it.
Instead of adding complexity to this rarely touched code, always draw into an
intermediate bitmap that we then paint into our QPainter afterward.

- Use CGBitmapContextCreate to allocate a buffer directly instead of creating a QPixmap
  and extract an CGContextRef out of it.
- Get rid of the "if (platformPluginWidget())" code path since we don't paint directly
  into the QWidget's backing store anymore.
- Always use m_contextRef to draw the plugin instead of alternating between direct and
  indirect drawing.

* plugins/PluginView.cpp:
(WebCore::PluginView::PluginView):
* plugins/PluginView.h:
* plugins/mac/PluginViewMac.mm:
(WebCore::createBitmapContext):
(WebCore::PluginView::platformStart):
(WebCore::PluginView::platformDestroy):
(WebCore::PluginView::setFocus):
(WebCore::PluginView::setNPWindowIfNeeded):
(WebCore::PluginView::updatePluginWidget):
(WebCore::PluginView::paint):
(WebCore::PluginView::invalidateRect):

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

Conflicts:
	Source/WebCore/plugins/PluginView.h
	Source/WebCore/plugins/mac/PluginViewMac.mm

Change-Id: I1006dcf3c08c14ca0d144532372de33f815fbc23
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] Re-enable plugins on Mac.

https://bugs.webkit.org/show_bug.cgi?id=116622
Reviewed by Tor Arne Vestbø.

Source/WebCore:

* platform/FileSystem.h:
* platform/qt/FileSystemQt.cpp:
(WebCore::unloadModule):
  - Q_WS_* aren't defined since Qt5, use Q_OS_MACX instead.
* plugins/mac/PluginPackageMac.cpp:
(WebCore::PluginPackage::fetchInfo):
(WebCore::PluginPackage::load):
  - createCFString now does the adoption itself.
* plugins/mac/PluginViewMac.mm:
  - Add missing include.

Source/WebKit/qt:

* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::windowResizerRect):
  - Add missing parenthese.

Tools:

Plugins on Mac were only enabled if !embedded but the later was set if
QPA is enabled, which is the default since Qt 5.0.

Remove references to 'embedded' and fix various build issues,
PluginViewMac.mm and PluginPackageMac.cpp haven't been compiled since a few
months.

* DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
* qmake/mkspecs/features/features.prf:
* qmake/mkspecs/features/unix/default_pre.prf:

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

Conflicts:
	Source/WebCore/platform/FileSystem.h
	Source/WebCore/plugins/mac/PluginPackageMac.cpp

Change-Id: I38dc6170ca868b54f8092aa6b271ace4911a2390
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] Fix a crash under ~PingLoader when the QNAM on the page has been destroyed.

https://bugs.webkit.org/show_bug.cgi?id=116035
Reviewed by Simon Hausmann.

Source/WebCore:

Reproduced with arora which does destroy the QNetworkAccessManager in some situations.
The problem is that PingLoader can still be pending meanwhile, holding a ResourceHandle
with a dangling pointer to a QNetworkReply destroyed with the QNetworkAccessManager.

* platform/network/qt/QNetworkReplyHandler.cpp:
(WebCore::QNetworkReplyWrapper::QNetworkReplyWrapper):
  Set the parent to 0 like we did before the introduction of QNetworkReplyWrapper.
(WebCore::QNetworkReplyWrapper::release):

Source/WebKit/qt:

* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::networkReplyParentChanged):

Change-Id: Id53db216a6252f8471d6fa97093312843213e48d
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150057 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] Fix a crash under ~PingLoader when the QNAM on the page has been destroyed.

https://bugs.webkit.org/show_bug.cgi?id=116035
Reviewed by Allan Sandfeld Jensen.

Source/WebCore:

The previous fix only moved the crash location from WebKit down to QNetworkReplyHttpImpl
which expects its QNetworkAccessManager to still be alive.

Fix it by watching the QNetworkReply's destroyed() signal and avoid the dangling pointer
instead. The QNetworkReply doesn't need to be aborted in this case anyway.

* platform/network/qt/QNetworkReplyHandler.cpp:
(WebCore::QNetworkReplyWrapper::QNetworkReplyWrapper):
(WebCore::QNetworkReplyWrapper::release):
(WebCore::QNetworkReplyWrapper::stopForwarding):
  Rename resetConnections to stopForwarding since not all connections are related
  to data forwarding to the client anymore.
(WebCore::QNetworkReplyWrapper::receiveMetaData):
(WebCore::QNetworkReplyWrapper::replyDestroyed):
(WebCore::QNetworkReplyWrapper::didReceiveFinished):
* platform/network/qt/QNetworkReplyHandler.h:
(QNetworkReplyWrapper):

Source/WebKit/qt:

* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::networkReplyParentDidntChange): Change test to match the new expectation.
(tst_QWebPage::destroyQNAMBeforeAbortDoesntCrash):

Change-Id: I5e82b8ccc8fccf496669af8de76888e367480f67
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Glyphs may fail to render when using SVG font

https://bugs.webkit.org/show_bug.cgi?id=115193

Reviewed by Simon Fraser.

Calling SimpleFontData::applyTransforms() when the font used is
an SVG font makes little sense since Core Text doesn’t know or
understand SVG fonts and would be passed some other, unrelated
platform font.

* platform/graphics/SimpleFontData.h:
(WebCore::SimpleFontData::applyTransforms):

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

Task-number: QTBUG-31663
Change-Id: Ic631da7c64e477c4f6199053584d36827bd3a5b1
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
Merge remote-tracking branch 'origin/release' into stable

Change-Id: I66f94d7e3dea401f7a89a00fb474532377baf6c4