Merge r164787 - [GTK] Web Inspector doesn't work with network process enabled
https://bugs.webkit.org/show_bug.cgi?id=127651

Reviewed by Sergio Villar Senin.

The problem is that the web inspector loads so many resources,
that when using the network process, a lot of IPC traffic is
generated causing the send buffer of the socket to be full. When
that happens sendmsg() fails with EAGAIN, because we are using non
blocking sockets, and we are not handling neither EAGAIN nor
EWOULDBLOCK errors (we do when reading from the socket, though).

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::readyReadHandler): Add a log message to know
when reading from the socket fails for any unhandled error.
(IPC::Connection::sendOutgoingMessage): Handle EAGAIN and
EWOULDBLOCK errors to try again in those cases. Also add a log
message for unhandled errors.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@164791 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r165745 - [GTK] Don't busy loop when the socket is full
https://bugs.webkit.org/show_bug.cgi?id=129802

Patch by Giovanni Campagna <gcampagna@src.gnome.org> on 2014-03-17
Reviewed by Carlos Garcia Campos.

When the socket is full and we see EAGAIN or EWOULDBLOCK
(because the socket is non blocking), don't busy loop by
tring to write again, instead poll() until the socket
becomes writable.

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::sendOutgoingMessage):

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r164808 - [GTK][WK2] Blocks when fetching plugins information
https://bugs.webkit.org/show_bug.cgi?id=115650

Reviewed by Gustavo Noronha Silva.

Use a persistent cache to store the plugins metadata to avoid
having to load all the plugins everytime a plugin is used for the
first time.

* GNUmakefile.am:
* GNUmakefile.list.am:
* PlatformGTK.cmake:
* Shared/Plugins/Netscape/NetscapePluginModule.h:
* Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:
(WebKit::NetscapePluginModule::parseMIMEDescription): Make this
method public.
(WebKit::NetscapePluginModule::buildMIMEDescription): Added this
helper to build the MIME description string.
* UIProcess/Plugins/gtk/PluginInfoCache.cpp: Added.
(WebKit::PluginInfoCache::shared):
(WebKit::PluginInfoCache::PluginInfoCache):
(WebKit::PluginInfoCache::~PluginInfoCache):
(WebKit::PluginInfoCache::saveToFileIdleCallback):
(WebKit::PluginInfoCache::saveToFile):
(WebKit::PluginInfoCache::getPluginInfo):
(WebKit::PluginInfoCache::updatePluginInfo):
* UIProcess/Plugins/gtk/PluginInfoCache.h: Added.
* UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp:
(WebKit::PluginInfoStore::getPluginInfo): Check first if we have
metadata of the plugin in the cache and update the cache if we
loaded the plugin to get its metadata.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r164980 - [GTK] webkit_dom_range_compare_boundary_points fails when 0 is passed as how parameter
https://bugs.webkit.org/show_bug.cgi?id=129145

Patch by Tomas Popela <tpopela@redhat.com> on 2014-03-03
Reviewed by Carlos Garcia Campos.

While generating GObject DOM API the generator should skip non pointer
types while generating the g_return_val_if_fail macro.
This will avoid the situation when Range.START_TO_START is defined as 0,
thus the webkit_dom_range_compare_boundary_points function will fail
everytime it is called with 0 as how value.

* bindings/scripts/CodeGeneratorGObject.pm:
(GenerateFunction):

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r165182 - [GTK] Close the page when the view is disposed instead of when finalized
https://bugs.webkit.org/show_bug.cgi?id=129783

Reviewed by Sergio Villar Senin.

Source/WebKit2:

When a GtkWidget is destroyed, the GObject is disposed, but not
finalized if it has additional references. When the destroyed
widget is leaked by the application, we leak the page proxy and
what is more important the web process in multi-process mode.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseDispose): Close the WebPageProxy.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r165489 - [GTK] Runtime error when page is closed while print operation is in progress
https://bugs.webkit.org/show_bug.cgi?id=129869

Reviewed by Anders Carlsson.

Sometimes when the page is closed right after printing the web
process aborts with the runtime message "pure virtual method
called terminate called without an active exception".
This happens because the page is closed when the pages have been
printed, but print job is still ongoing sending the data to the
printer. When print job finishes, we try to notify the UI process
sending the print callback message using WebPage::send(), but the
web page object has been destroyed. The virtual method it complains
about is probably MessageSender::messageSenderDestinationID() used
by send(). Since our print operation is always asynchronous, we
need a way to notify the web page when the print operation has
actually finished to clean it up, but also notify the print
operation when the page has been closed to not try to notify the
UI process in that case.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close): Call disconnectFromPage to notify the
print operation in case there's an ongoing print job.
(WebKit::WebPage::endPrinting): Do not cleanup the print operation
here, since the print opertation might not have finished yet.
(WebKit::WebPage::didFinishPrintOperation): Send
PrintFinishedCallback message to the Ui process and cleanup the
print operation.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::WebPrintOperationGtk::disconnectFromPage): Set m_webPage
to nullptr.
(WebKit::WebPrintOperationGtk::printDone): Call
didFinishPrintOperation() is the web page hasn't been closed.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.h:

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r165371 - [GTK] The web process can finish while a print operation is still ongoing
https://bugs.webkit.org/show_bug.cgi?id=129871

Reviewed by Martin Robinson.

This can happen when the last page is closed while the print job
is sending data to the printer.

* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp: Disable web
process termination when the print job is sending data to the
printer and enable it again when job finishes.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165884 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r165550 - [GTK] Close the connection when we fail to read from the socket for any unhandled error
https://bugs.webkit.org/show_bug.cgi?id=130191

Reviewed by Martin Robinson.

We currently show an error message, but we should close the
connection avoid entering an infinite loop. Also provide more
information in the error message to help when debugging the issue.

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::readyReadHandler):

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r165812 - [GTK] Race condition when the socket event source is cancelled
https://bugs.webkit.org/show_bug.cgi?id=130395

Reviewed by Martin Robinson.

In some cases when the socket event source is cancelled the socket
event source callback is called with the condition of the previous
poll instead of 0. This can happen sometimes when the source is
cancelled from the socket event source callback. Once the socket
event source is cancelled, it's dispatched by glib without
polling, so the condition is never reset again and the callback is
called again and again with the previous condition. When the
condition is G_IO_IN, the source is re-scheduled entering into an
infinite loop. We should always check if the source has been
cancelled at the beginning of the callback to destroy the source
instead of relying on the condition being 0.

* Platform/gtk/WorkQueueGtk.cpp:
(WorkQueue::SocketEventSource::isCancelled):
(WorkQueue::SocketEventSource::eventCallback):

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Update NEWS and Versions.m4 for 2.2.6 release.

.:

* Source/autotools/Versions.m4: Bump version numbers.

Source/WebKit/gtk:

* NEWS: Add release notes.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@165887 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r166480 - [GTK] [TextureMapper] Weird brightness with some videos with acceletared compositing
https://bugs.webkit.org/show_bug.cgi?id=130665

Reviewed by Martin Robinson.

When we uploaded a video texture to the mapper we were not
considering that some videos could be decoded into a format
without alpha component. Now we check if the video has alpha and
if it does not, we remove the alpha flag when retrieving the
texture from the pool. For this, the method to get the texture
from the pool was modified to receive the flags, that is mapped to
have alpha by default in order not to break any other existing
code.

Though we have a problem with AC in WTR and that makes it
currently not testable, no new tests are needed because once this
is fixed the current test set suffices to detect a possible
regression in this.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): Check
the video format and decide if the texture shall be pulled with
alpha support or not.
* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::TextureMapper::acquireTextureFromPool): Use the flags
when resetting the texture.
* platform/graphics/texmap/TextureMapper.h:
(WebCore::BitmapTexture::Flag::None): Added with 0x00.
(WebCore::TextureMapper::acquireTextureFromPool): Added flag
parameter to set up the texture with the default for including
alpha channel.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167986 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r166574 - [GTK] Don't copy the ResourceResponse object in webkitWebViewDecidePolicy
https://bugs.webkit.org/show_bug.cgi?id=131015

Reviewed by Carlos Garcia Campos.

* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewDecidePolicy): Avoid copying the ResourceResponce object returned by webkitURIResponseGetResourceResponse.
That function already returns a reference, so the return value should be stored accordingly.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r167883 - [GTK] Crash in debug build with removing windowed plugin child widgets from the view
https://bugs.webkit.org/show_bug.cgi?id=132252

Reviewed by Philippe Normand.

It crashes due to an assert in HashTable that checks the iterators
validity. The problem is that we are iterating the children map
and the callback called on every iteration might modify the map,
making the iterators invalid. This happens when the WebView is
destroyed, GtkContainer calls gtk_container_foreach() with
gtk_widget_destroy as callback. When a widget inside a container
is destroyed, it's removed from the container, and in our case,
the child widget is removed from the map. This fixes several
crashes when running layout tests in debug bot.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseContainerForall): Use copyKeysToVector() instead
of using a range iterator for the map keys and check in every
iteration that the child widget from the keys vector is still
present in the map before calling the callback.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. [GTK] Plugin process crashes when loading totem plugin
https://bugs.webkit.org/show_bug.cgi?id=131357

Make Netscape browser functions static to avoid conflicts with
plugins defining those functions as well.

* GNUmakefile.list.am: Do not build npapi.cpp.
* plugins/PluginPackage.cpp:
(WebCore::pluginViewForInstance):
(WebCore::NPN_MemAlloc):
(WebCore::NPN_MemFree):
(WebCore::NPN_MemFlush):
(WebCore::NPN_ReloadPlugins):
(WebCore::NPN_RequestRead):
(WebCore::NPN_GetURLNotify):
(WebCore::NPN_GetURL):
(WebCore::NPN_PostURLNotify):
(WebCore::NPN_PostURL):
(WebCore::NPN_NewStream):
(WebCore::NPN_Write):
(WebCore::NPN_DestroyStream):
(WebCore::NPN_UserAgent):
(WebCore::NPN_Status):
(WebCore::NPN_InvalidateRect):
(WebCore::NPN_InvalidateRegion):
(WebCore::NPN_ForceRedraw):
(WebCore::NPN_GetValue):
(WebCore::NPN_SetValue):
(WebCore::NPN_GetJavaEnv):
(WebCore::NPN_GetJavaPeer):
(WebCore::NPN_PushPopupsEnabledState):
(WebCore::NPN_PopPopupsEnabledState):
(WebCore::NPN_PluginThreadAsyncCall):
(WebCore::NPN_GetValueForURL):
(WebCore::NPN_SetValueForURL):
(WebCore::NPN_GetAuthenticationInfo):
(WebCore::NPN_PopUpContextMenu):
* plugins/PluginPackage.h:
(WebCore::PluginPackage::browserFuncs): Add accessor to browser
function pointers.
* plugins/PluginView.cpp:
(WebCore::PluginView::stop): Use browser function pointers instead
of NPN wrappers that are now private.
(WebCore::PluginView::getValueForURL): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167990 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r167116 - [GTK][WK2] Move Vector objects into WebEditorClient::executePendingEditorCommands() invocations
https://bugs.webkit.org/show_bug.cgi?id=131454

Reviewed by Carlos Garcia Campos.

* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::executePendingEditorCommands): Take a const reference of the Vector
object to avoid unnecessary copies. Also deploy two range-based for loops and efficiently move
the Editor::Command objects into the other Vector.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167991 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r167128 - wk2-gtk does not display anything
https://bugs.webkit.org/show_bug.cgi?id=125558

Reviewed by Martin Robinson.

Remove fcntl call to set access mode flags on the duplicated files
descriptor. Those flags are ignored in Linux and make fcntl to
fail in FreeBSD. We should handle the case where the passed
protection is ReadOnly.
Thanks to Raphael Kubo da Costa who proposed the solution.

* Platform/unix/SharedMemoryUnix.cpp:
(WebKit::SharedMemory::createHandle):
(WebKit::accessModeFile): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r164170 - ASSERT_WITH_SECURITY_IMPLICATION in WebCore::toElement
https://bugs.webkit.org/show_bug.cgi?id=128810

Patch by Renata Hodovan <rhodovan.u-szeged@partner.samsung.com> on 2014-02-15
Reviewed by Ryosuke Niwa.

Source/WebCore:

Make CompositeEditCommand::cloneParagraphUnderNewElement() to work when |outerNode|
doesn't contain |start|.

Before this patch, CompositeEditCommand::cloneParagraphUnderNewElement() tried to copy
ancestry nodes from |start| to Document node when |start| position isn't in |outerNode|. This
patch changes CompositeEditCommand::cloneParagraphUnderNewElement() to copy |start| to
|outerNode| only if |outerNode| contains |start| position.

Merged from Blink https://src.chromium.org/viewvc/blink?revision=161762&view=revision by yosin@chromium.org.

Test: editing/execCommand/indent-with-uneditable-crash.html

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):

LayoutTests:

* editing/execCommand/indent-with-uneditable-crash-expected.txt: Added.
* editing/execCommand/indent-with-uneditable-crash.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167994 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r164204 - Ensure that removing an iframe from the DOM tree disconnects its Frame.
<https://webkit.org/b/128889>
<rdar://problem/15671221>

Merged from Blink (patch by Adam Klein):
https://src.chromium.org/viewvc/blink?revision=156174&view=revision

Source/WebCore:

SubframeLoadingDisabler wasn't catching the case when an <iframe> was,
in its unload handler, removed and re-added to the same parent.
Fix this by using a count of SubframeLoadingDisablers that are on the
stack for a given root, rather than a simple boolean.

Test: fast/frames/reattach-in-unload.html

* html/HTMLFrameOwnerElement.h:
(WebCore::SubframeLoadingDisabler::disabledSubtreeRoots):

LayoutTests:

* fast/frames/reattach-in-unload-expected.txt: Added.
* fast/frames/reattach-in-unload.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r164367 - Do not dispatch change event twice in single step action
https://bugs.webkit.org/show_bug.cgi?id=116936
<rdar://problem/16086828>

Reviewed by Ryosuke Niwa.

Merged from Blink (patch by Kent Tamura):
https://src.chromium.org/viewvc/blink?view=rev&revision=151175

Source/WebCore:

Test: fast/forms/number/number-type-update-by-change-event.html

* html/InputType.cpp:
(WebCore::InputType::stepUpFromRenderer):

LayoutTests:

* fast/forms/number/number-type-update-by-change-event-expected.txt: Added.
* fast/forms/number/number-type-update-by-change-event.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge r164408 - Crash in WTF::StringBuilder::append()

https://bugs.webkit.org/show_bug.cgi?id=125817
<rdar://problem/15671883>

Reviewed by Oliver Hunt.

* wtf/text/StringBuilder.cpp:
(WTF::expandedCapacity):
Ensure that we return a new capacity of at least 'requiredLength' in
the case where requiredLength is large. Also, use unsigned rather than
size_t for the parameters and the return value, as callers pass
unsigned arguments and treat the result as an unsigned int.

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.2@167997 268f45cc-cd09-0410-ab3c-d52691b4dbfc