[Qt][WK2] Favor QUrl and QString over WTF::String in the Qt API layer
https://bugs.webkit.org/show_bug.cgi?id=109468

Reviewed by Allan Sandfeld Jensen.
Signed off for WebKit2 by Benjamin Poulain.

In preparation for patches using the C API types in some areas, remove the
usage of WTF::String on the affected line.

Use a QUrl for icon URL to avoid unnecessary conversion.
Use a QString for the page URL to keep it compatible with WebPageProxy and
WebIconDatabase and avoid QUrl parsing.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::_q_onIconChangedForPageURL):
(QQuickWebViewPrivate::updateIcon):
(QQuickWebView::emitUrlChangeIfNeeded):
(QQuickWebView::icon):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/API/qt/qwebiconimageprovider.cpp:
(QWebIconImageProvider::iconURLForPageURLInContext):
* UIProcess/API/qt/qwebiconimageprovider_p.h:
* UIProcess/qt/QtWebIconDatabaseClient.cpp:
(WebKit::QtWebIconDatabaseClient::iconForPageURL):
(WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
(WebKit::QtWebIconDatabaseClient::retainIconForPageURL):
(WebKit::QtWebIconDatabaseClient::releaseIconForPageURL):
* UIProcess/qt/QtWebIconDatabaseClient.h:
(QtWebIconDatabaseClient):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt][WK2] Keep the WebContext alive during the whole application's lifetime
https://bugs.webkit.org/show_bug.cgi?id=109827

Reviewed by Simon Hausmann.
Signed off for WebKit2 by Benjamin Poulain.

The lifetime of the WebContext is difficult to manage because of a circular
reference kept with the WebProcessProxy until it shuts itself down, 60
seconds after the last page is closed. There was some notification
in place to handle this in the upper layer, but having to go through the
C API (done in a following patch) makes this quite awkward.

Keeping the WebContext alive also includes the icon database which is
quite heavy, in the future we should only enable it once the
QQuickWebView::icon property is read.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(QQuickWebViewPrivate::handleDownloadRequest):
(QQuickWebViewPrivate::updateIcon):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/API/qt/qwebiconimageprovider.cpp:
(QWebIconImageProvider::requestImage):
* UIProcess/qt/QtWebContext.cpp:
(WebKit):
(WebKit::QtWebContext::QtWebContext):
(WebKit::QtWebContext::~QtWebContext):
(WebKit::QtWebContext::create):
(WebKit::QtWebContext::defaultContext):
* UIProcess/qt/QtWebContext.h:
(QtWebContext):
(WebKit::QtWebContext::downloadManager):
(WebKit::QtWebContext::iconDatabase):
* UIProcess/qt/WebContextQt.cpp:
(WebKit::WebContext::platformInvalidateContext):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145513 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Refactoring: Pull Node::disabled() and Node::isInert() down to Element.
https://bugs.webkit.org/show_bug.cgi?id=112085

Reviewed by Hajime Morrita.

Node is too low a level for these methods.

No new tests, just refactoring.

* dom/Element.cpp:
(WebCore::Element::disabled):
(WebCore):
(WebCore::Element::isInert):
* dom/Element.h:
(Element):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchSimulatedClick):
* dom/GestureEvent.cpp:
(WebCore::GestureEventDispatchMediator::dispatchEvent):
* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::dispatchEvent):
* dom/Node.cpp:
(WebCore::Node::handleLocalEvents):
(WebCore::Node::willRespondToMouseMoveEvents):
(WebCore::Node::willRespondToMouseClickEvents):
(WebCore::Node::willRespondToTouchEvents):
* dom/Node.h:
(Node):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145514 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt][WK2] Allow QtWebContext to call directly to QQuickWebView with a WKPageRef
https://bugs.webkit.org/show_bug.cgi?id=109829

Reviewed by Allan Sandfeld Jensen.
Signed off for WebKit2 by Benjamin Poulain.

Instead of going through WebPageProxy and PageClient to forward
injected bundle messages received by the context, maintain a static map
of WKPageRef to QQuickWebViewPrivate.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::get):
(QQuickWebViewPrivate::~QQuickWebViewPrivate):
(QQuickWebViewPrivate::initialize):
(QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/API/qt/raw/qrawwebview.cpp:
* UIProcess/API/qt/raw/qrawwebview_p_p.h:
* UIProcess/PageClient.h:
(PageClient):
* UIProcess/WebPageProxy.h:
(WebPageProxy):
* UIProcess/qt/QtPageClient.cpp:
* UIProcess/qt/QtPageClient.h:
(QtPageClient):
* UIProcess/qt/QtWebContext.cpp:
(WebKit::didReceiveMessageFromInjectedBundle):
* UIProcess/qt/WebPageProxyQt.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145515 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] Properly layer QtWebContext on top of the C API
https://bugs.webkit.org/show_bug.cgi?id=108475

Reviewed by Simon Hausmann.
Signed off for WebKit2 by Benjamin Poulain.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::initialize):
* UIProcess/qt/QtWebContext.cpp:
(WebKit::initializeContextInjectedBundleClient):
(WebKit::QtWebContext::QtWebContext):
(WebKit::QtWebContext::create):
(WebKit::QtWebContext::defaultContext):
* UIProcess/qt/QtWebContext.h:
(WebKit):
(QtWebContext):
(WebKit::QtWebContext::context):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt][WK2] Specify storage paths through the C API
https://bugs.webkit.org/show_bug.cgi?id=111435

Reviewed by Simon Hausmann.
Signed off for WebKit2 by Benjamin Poulain.

The WKIconDatabase should be opened through a call to
WKContextSetIconDatabasePath. To avoid having some paths
returned through WebContext::platformDefault* and some others
through the C API, make sure that all those paths are set
through the C API.

* Shared/qt/QtDefaultDataLocation.cpp: Removed.
* Shared/qt/QtDefaultDataLocation.h: Removed.
* Target.pri:
* UIProcess/Plugins/qt/PluginProcessProxyQt.cpp:
(WebKit::cacheFile):
  - This part is left alone behind the C API.
    Since PluginProcessProxy have no knowledge of the WebContext
    it is rather difficult to fetch a configured directory that
    could be used for this purpose (like the disk cache storage).
    Hard-code a compatible logic to keep the current behavior.
(WebKit::removeCacheFile):
(WebKit):
(WebKit::readMetaDataFromCacheFile):
(WebKit::writeToCacheFile):
(WebKit::tryReadPluginMetaDataFromCacheFile):
  - Update the code to better handle an empty cache file path.
* UIProcess/qt/QtWebContext.cpp:
(WebKit::QtWebContext::defaultContext):
(WebKit::defaultLocation):
(WebKit):
(WebKit::QtWebContext::preparedStoragePath):
* UIProcess/qt/QtWebContext.h:
* UIProcess/qt/QtWebIconDatabaseClient.cpp:
(WebKit::QtWebIconDatabaseClient::QtWebIconDatabaseClient):
* UIProcess/qt/WebContextQt.cpp:
(WebKit::WebContext::applicationCacheDirectory):
(WebKit::WebContext::platformDefaultDatabaseDirectory):
(WebKit::WebContext::platformDefaultIconDatabasePath):
(WebKit::WebContext::platformDefaultLocalStorageDirectory):
(WebKit::WebContext::platformDefaultDiskCacheDirectory):
(WebKit::WebContext::platformDefaultCookieStorageDirectory):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145517 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt][WK2] Layer QtWebIconDatabaseClient on the C API
https://bugs.webkit.org/show_bug.cgi?id=109564

Reviewed by Simon Hausmann.
Signed off for WebKit2 by Benjamin Poulain.

* Target.pri:
* UIProcess/API/C/qt/WKIconDatabaseQt.cpp: Added.
(WKIconDatabaseTryGetQImageForURL):
  - New API added to get a QImage from the IconDatabase.
    Based on WKIconDatabaseCG.h/cpp
* UIProcess/API/C/qt/WKIconDatabaseQt.h: Added.
* UIProcess/API/cpp/qt/WKURLQt.cpp:
(WKURLCreateWithQString):
(WKURLCopyQString):
(WKURLCreateWithQUrl):
(WKURLCopyQUrl):
  - The WKUrlRef behind the scene is a WTF::String and encoding it back and forth to
    a QUrl can slightly change its string representation. Allow converting a WKUrlRef
    to and from a QString to ensure this.
* UIProcess/API/cpp/qt/WKURLQt.h:
* UIProcess/API/qt/qwebiconimageprovider.cpp:
(QWebIconImageProvider::iconURLForPageURLInContext):
  - The icon URL isn't accessible form the C API and shouldn't need to be.
    Use an ID incremented on each update to trigger an update of the QML Image component.
(QWebIconImageProvider::requestImage):
  - The IconDatabase was previously assumed to resize the image to the requested size,
    but this parameter is ignored, as stated in a comment in WebIconDatabase::imageForPageURL.
    Explicitely do the resize after fetching the original icon to also be able to report
    the original size properly to QtQuick.
* UIProcess/API/qt/qwebiconimageprovider_p.h:
* UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml:
  - Set the image to load asynchronously to further test the possibility of threading issues
    in QtWebIconDatabaseClient::iconImageForPageURL
  - Add a few barriers to fix some issues where the load succeeded signal would be wrongly
    catched by init() before the next test.
* UIProcess/qt/QtWebContext.cpp:
(WebKit::QtWebContext::QtWebContext):
* UIProcess/qt/QtWebIconDatabaseClient.cpp:
(WebKit):
(WebKit::QtWebIconDatabaseClient::QtWebIconDatabaseClient):
(WebKit::QtWebIconDatabaseClient::~QtWebIconDatabaseClient):
(WebKit::QtWebIconDatabaseClient::updateID):
(WebKit::QtWebIconDatabaseClient::didChangeIconForPageURL):
(WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
  - Remove the Mutex. This mutex was useless given that it would only
    be locked from a single thread. Since the IconDatabase runs in its own thread,
    it already is thread-safe to access.
(WebKit::QtWebIconDatabaseClient::retainIconForPageURL):
(WebKit::QtWebIconDatabaseClient::releaseIconForPageURL):
* UIProcess/qt/QtWebIconDatabaseClient.h:
(QtWebIconDatabaseClient):
* WebKit2.pri:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt][WK2] Layer QtDownloadManager on the C API
https://bugs.webkit.org/show_bug.cgi?id=109562

Reviewed by Simon Hausmann.
Signed off for WebKit2 by Benjamin Poulain.

* UIProcess/API/cpp/qt/WKURLQt.cpp:
(WebKit::adoptToQString):
(WebKit):
(WebKit::adoptToQUrl):
* UIProcess/API/cpp/qt/WKURLQt.h:
(WebKit):
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::handleDownloadRequest):
* UIProcess/qt/QtDownloadManager.cpp:
(WebKit::toQtDownloadManager):
(WebKit):
(WebKit::QtDownloadManager::QtDownloadManager):
(WebKit::QtDownloadManager::addDownload):
(WebKit::QtDownloadManager::didReceiveResponse):
(WebKit::QtDownloadManager::didCreateDestination):
(WebKit::QtDownloadManager::didFinishDownload):
(WebKit::QtDownloadManager::didFailDownload):
(WebKit::QtDownloadManager::didReceiveDataForDownload):
* UIProcess/qt/QtDownloadManager.h:
(WebKit):
(QtDownloadManager):
* UIProcess/qt/QtWebContext.cpp:
(WebKit::QtWebContext::QtWebContext):
* UIProcess/qt/QtWebError.cpp:
(WebKit::QtWebError::url):
(WebKit::QtWebError::description):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145519 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: [CodeMirror] highlight matching braces
https://bugs.webkit.org/show_bug.cgi?id=112041

Patch by Andrey Lushnikov <lushnikov@chromium.org> on 2013-03-12
Reviewed by Vsevolod Vlasov.

Add "matchbrackets" add-on to CodeMirror text editor add override
default styles for matched and unmatched braces.

No new tests.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* inspector/front-end/CodeMirrorTextEditor.js:
(WebInspector.CodeMirrorTextEditor):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/cm/cmdevtools.css:
(.CodeMirror-matchingbracket):
(.CodeMirror-nonmatchingbracket):
* inspector/front-end/cm/matchbrackets.js: Added.
(.):

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