summaryrefslogtreecommitdiff
path: root/Source/WebKit2
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-10 13:08:05 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-10 13:08:05 +0200
commit81cbb264cb9446c4408124d50aeff50164ad0ab4 (patch)
tree6acc39b8ea0165562d480f1c54608c6c4ae9f865 /Source/WebKit2
parentbeaeeb99881184fd368c121fcbb1a31c78b794a3 (diff)
parent5087e0ced43d813eb6f765913a6fc3958d2a7a9d (diff)
downloadqtwebkit-81cbb264cb9446c4408124d50aeff50164ad0ab4.tar.gz
Merge remote-tracking branch 'origin/5.212' into dev
Change-Id: I4e185b15690118515df80a79b786cbb8b30dd144
Diffstat (limited to 'Source/WebKit2')
-rw-r--r--Source/WebKit2/PlatformQt.cmake3
-rw-r--r--Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp6
-rw-r--r--Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h25
-rw-r--r--Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp4
-rw-r--r--Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp2
-rw-r--r--Source/WebKit2/Scripts/webkit/Messages-expected.h25
-rw-r--r--Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h5
-rw-r--r--Source/WebKit2/Scripts/webkit/messages.py71
-rw-r--r--Source/WebKit2/Scripts/webkit/messages_unittest.py142
-rw-r--r--Source/WebKit2/Scripts/webkit/model.py3
-rw-r--r--Source/WebKit2/Scripts/webkit/parser.py3
-rw-r--r--Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp15
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp36
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h10
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h4
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp3
-rw-r--r--Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp12
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.cpp2
-rw-r--r--Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h57
-rw-r--r--Source/WebKit2/UIProcess/qt/DialogContextObjects.h287
-rw-r--r--Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp181
-rw-r--r--Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h119
-rw-r--r--Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp262
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPageClient.cpp3
-rw-r--r--Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp29
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp227
-rw-r--r--Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp4
-rw-r--r--Source/WebKit2/WebProcess/qt/WebProcessQt.cpp6
30 files changed, 895 insertions, 655 deletions
diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake
index 5883096eb..a033f1cf1 100644
--- a/Source/WebKit2/PlatformQt.cmake
+++ b/Source/WebKit2/PlatformQt.cmake
@@ -156,6 +156,9 @@ list(APPEND WebKit2_SOURCES
UIProcess/gstreamer/WebPageProxyGStreamer.cpp
UIProcess/qt/BackingStoreQt.cpp
+ UIProcess/qt/ColorChooserContextObject.h
+ UIProcess/qt/DialogContextObjects.h
+ UIProcess/qt/ItemSelectorContextObject.cpp
UIProcess/qt/PageViewportControllerClientQt.cpp
UIProcess/qt/QrcSchemeHandler.cpp
UIProcess/qt/QtDialogRunner.cpp
diff --git a/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp b/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp
index 240fc7374..040c722ef 100644
--- a/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp
+++ b/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp
@@ -104,7 +104,7 @@ bool TestMultipleAttributes::DelayedReply::send()
namespace WebKit {
-void WebPage::didReceiveWebPageMessage(IPC::Connection*, IPC::MessageDecoder& decoder)
+void WebPage::didReceiveWebPageMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
{
if (decoder.messageName() == Messages::WebPage::LoadURL::name()) {
IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL);
@@ -184,11 +184,12 @@ void WebPage::didReceiveWebPageMessage(IPC::Connection*, IPC::MessageDecoder& de
return;
}
#endif
+ UNUSED_PARAM(connection);
UNUSED_PARAM(decoder);
ASSERT_NOT_REACHED();
}
-void WebPage::didReceiveSyncWebPageMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
+void WebPage::didReceiveSyncWebPageMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
{
if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) {
IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin);
@@ -216,6 +217,7 @@ void WebPage::didReceiveSyncWebPageMessage(IPC::Connection* connection, IPC::Mes
return;
}
#endif
+ UNUSED_PARAM(connection);
UNUSED_PARAM(decoder);
UNUSED_PARAM(replyEncoder);
ASSERT_NOT_REACHED();
diff --git a/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h b/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h
index 6397c1043..50e1ca41f 100644
--- a/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h
+++ b/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h
@@ -27,13 +27,27 @@
#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND))
+#include "ArgumentCoders.h"
#include "Arguments.h"
#include "Connection.h"
+#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE)
+#include "DummyType.h"
+#endif
+#if PLATFORM(MAC)
+#include "MachPort.h"
+#endif
#include "MessageEncoder.h"
#include "Plugin.h"
#include "StringReference.h"
+#include "WebCoreArgumentCoders.h"
+#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION))
+#include "WebEvent.h"
+#endif
+#include "WebPreferencesStore.h"
#include <WebCore/GraphicsLayer.h>
+#if PLATFORM(MAC)
#include <WebCore/KeyboardEvent.h>
+#endif
#include <WebCore/PluginData.h>
#include <utility>
#include <wtf/HashMap.h>
@@ -43,17 +57,6 @@
namespace IPC {
class Connection;
- class DummyType;
- class MachPort;
-}
-
-namespace WTF {
- class String;
-}
-
-namespace WebKit {
- struct WebPreferencesStore;
- class WebTouchEvent;
}
namespace Messages {
diff --git a/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp b/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp
index 8d5e13dea..877e5129c 100644
--- a/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp
+++ b/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp
@@ -104,7 +104,7 @@ bool TestMultipleAttributes::DelayedReply::send()
namespace WebKit {
-void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
+void WebPage::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
{
if (decoder.messageName() == Messages::WebPage::LoadURL::name()) {
IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL);
@@ -189,7 +189,7 @@ void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder
ASSERT_NOT_REACHED();
}
-void WebPage::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
+void WebPage::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
{
if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) {
IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin);
diff --git a/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp b/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp
index c6889781f..b498e9d9a 100644
--- a/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp
+++ b/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp
@@ -34,7 +34,7 @@
namespace WebKit {
-void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
+void WebPage::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
{
if (decoder.messageName() == Messages::WebPage::LoadURL::name()) {
IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL);
diff --git a/Source/WebKit2/Scripts/webkit/Messages-expected.h b/Source/WebKit2/Scripts/webkit/Messages-expected.h
index 6397c1043..50e1ca41f 100644
--- a/Source/WebKit2/Scripts/webkit/Messages-expected.h
+++ b/Source/WebKit2/Scripts/webkit/Messages-expected.h
@@ -27,13 +27,27 @@
#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND))
+#include "ArgumentCoders.h"
#include "Arguments.h"
#include "Connection.h"
+#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE)
+#include "DummyType.h"
+#endif
+#if PLATFORM(MAC)
+#include "MachPort.h"
+#endif
#include "MessageEncoder.h"
#include "Plugin.h"
#include "StringReference.h"
+#include "WebCoreArgumentCoders.h"
+#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION))
+#include "WebEvent.h"
+#endif
+#include "WebPreferencesStore.h"
#include <WebCore/GraphicsLayer.h>
+#if PLATFORM(MAC)
#include <WebCore/KeyboardEvent.h>
+#endif
#include <WebCore/PluginData.h>
#include <utility>
#include <wtf/HashMap.h>
@@ -43,17 +57,6 @@
namespace IPC {
class Connection;
- class DummyType;
- class MachPort;
-}
-
-namespace WTF {
- class String;
-}
-
-namespace WebKit {
- struct WebPreferencesStore;
- class WebTouchEvent;
}
namespace Messages {
diff --git a/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h b/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h
index 9b353a040..89167b6b3 100644
--- a/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h
+++ b/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h
@@ -25,13 +25,12 @@
#ifndef WebPageMessages_h
#define WebPageMessages_h
+#include "ArgumentCoders.h"
#include "Arguments.h"
#include "MessageEncoder.h"
#include "StringReference.h"
+#include <wtf/text/WTFString.h>
-namespace WTF {
- class String;
-}
namespace Messages {
namespace WebPage {
diff --git a/Source/WebKit2/Scripts/webkit/messages.py b/Source/WebKit2/Scripts/webkit/messages.py
index b71df91b6..4b786fe62 100644
--- a/Source/WebKit2/Scripts/webkit/messages.py
+++ b/Source/WebKit2/Scripts/webkit/messages.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -23,6 +23,7 @@
import collections
import re
import sys
+
from webkit import parser
WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection'
@@ -168,11 +169,11 @@ def forward_declarations_for_namespace(namespace, kind_and_types):
def forward_declarations_and_headers(receiver):
types_by_namespace = collections.defaultdict(set)
- headers = set([
- '"Arguments.h"',
- '"MessageEncoder.h"',
- '"StringReference.h"',
- ])
+ header_conditions = {
+ '"Arguments.h"' : [],
+ '"MessageEncoder.h"' : [],
+ '"StringReference.h"': []
+ }
non_template_wtf_types = frozenset([
'String',
@@ -180,38 +181,47 @@ def forward_declarations_and_headers(receiver):
for message in receiver.messages:
if message.reply_parameters != None and message.has_attribute(DELAYED_ATTRIBUTE):
- headers.add('<wtf/ThreadSafeRefCounted.h>')
+ header_conditions['<wtf/ThreadSafeRefCounted.h>'] = []
types_by_namespace['IPC'].update([('class', 'Connection')])
+ type_conditions = {}
for parameter in receiver.iterparameters():
- kind = parameter.kind
- type = parameter.type
+ if not parameter.type in type_conditions:
+ type_conditions[parameter.type] = []
- if type.find('<') != -1:
- # Don't forward declare class templates.
- headers.update(headers_for_type(type))
- continue
+ if not parameter.condition in type_conditions[parameter.type]:
+ type_conditions[parameter.type].append(parameter.condition)
- split = type.split('::')
+ for parameter in receiver.iterparameters():
+ type = parameter.type
+ conditions = type_conditions[type]
- # Handle WTF types even if the WTF:: prefix is not given
- if split[0] in non_template_wtf_types:
- split.insert(0, 'WTF')
+ argument_encoder_headers = argument_coder_headers_for_type(type)
+ if argument_encoder_headers:
+ for header in argument_encoder_headers:
+ if header not in header_conditions:
+ header_conditions[header] = []
+ header_conditions[header].extend(conditions)
- if len(split) == 2:
- namespace = split[0]
- inner_type = split[1]
- types_by_namespace[namespace].add((kind, inner_type))
- elif len(split) > 2:
- # We probably have a nested struct, which means we can't forward declare it.
- # Include its header instead.
- headers.update(headers_for_type(type))
+ type_headers = headers_for_type(type)
+ for header in type_headers:
+ if header not in header_conditions:
+ header_conditions[header] = []
+ header_conditions[header].extend(conditions)
forward_declarations = '\n'.join([forward_declarations_for_namespace(namespace, types) for (namespace, types) in sorted(types_by_namespace.items())])
- headers = ['#include %s\n' % header for header in sorted(headers)]
+ headers = []
+ for header in sorted(header_conditions):
+ if header_conditions[header] and not None in header_conditions[header]:
+ headers.append('#if %s\n' % ' || '.join(set(header_conditions[header])))
+ headers += ['#include %s\n' % header]
+ headers.append('#endif\n')
+ else:
+ headers += ['#include %s\n' % header]
return (forward_declarations, headers)
+
def generate_messages_header(file):
receiver = parser.parse(file)
header_guard = messages_header_filename(receiver).replace('.', '_')
@@ -302,7 +312,7 @@ def class_template_headers(template_string):
match = re.match('(?P<template_name>.+?)<(?P<parameter_string>.+)>', template_string)
if not match:
- return {'header_infos':[], 'types':[template_string]}
+ return {'header_infos': [], 'types': [template_string]}
template_name = match.groupdict()['template_name']
if template_name not in class_template_types:
@@ -315,10 +325,10 @@ def class_template_headers(template_string):
for parameter in parser.split_parameters_string(match.groupdict()['parameter_string']):
parameter_header_infos_and_types = class_template_headers(parameter)
- header_infos += parameter_header_infos_and_types['header_infos'];
+ header_infos += parameter_header_infos_and_types['header_infos']
types += parameter_header_infos_and_types['types']
- return {'header_infos':header_infos, 'types':types}
+ return {'header_infos': header_infos, 'types': types}
def argument_coder_headers_for_type(type):
@@ -346,6 +356,7 @@ def argument_coder_headers_for_type(type):
return headers
+
def headers_for_type(type):
header_infos_and_types = class_template_headers(type)
@@ -402,6 +413,7 @@ def headers_for_type(type):
return headers
+
def generate_message_handler(file):
receiver = parser.parse(file)
header_conditions = {
@@ -452,7 +464,6 @@ def generate_message_handler(file):
header_conditions[header] = []
header_conditions[header].append(message.condition)
-
result = []
result.append(_license_header)
diff --git a/Source/WebKit2/Scripts/webkit/messages_unittest.py b/Source/WebKit2/Scripts/webkit/messages_unittest.py
index e12dfd41e..164199fc2 100644
--- a/Source/WebKit2/Scripts/webkit/messages_unittest.py
+++ b/Source/WebKit2/Scripts/webkit/messages_unittest.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -21,44 +21,33 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
+import re
+import sys
import unittest
from StringIO import StringIO
-import messages
-import parser
-
-print os.getcwd()
+sys.path.append(os.path.dirname(os.path.dirname(__file__)))
+from webkit import messages
+from webkit import parser
script_directory = os.path.dirname(os.path.realpath(__file__))
-with open(os.path.join(script_directory, 'test-messages.in')) as file:
- _messages_file_contents = file.read()
-
-with open(os.path.join(script_directory, 'test-legacy-messages.in')) as file:
- _legacy_messages_file_contents = file.read()
-
-with open(os.path.join(script_directory, 'test-superclass-messages.in')) as file:
- _superclass_messages_file_contents = file.read()
-
-
-with open(os.path.join(script_directory, 'Messages-expected.h')) as file:
- _expected_receiver_header = file.read()
+with open(os.path.join(script_directory, 'test-messages.in')) as in_file:
+ _messages_file_contents = in_file.read()
-with open(os.path.join(script_directory, 'LegacyMessages-expected.h')) as file:
- _expected_legacy_receiver_header = file.read()
+with open(os.path.join(script_directory, 'test-legacy-messages.in')) as in_file:
+ _legacy_messages_file_contents = in_file.read()
-with open(os.path.join(script_directory, 'MessagesSuperclass-expected.h')) as file:
- _expected_superclass_receiver_header = file.read()
-
+with open(os.path.join(script_directory, 'test-superclass-messages.in')) as in_file:
+ _superclass_messages_file_contents = in_file.read()
-with open(os.path.join(script_directory, 'MessageReceiver-expected.cpp')) as file:
- _expected_receiver_implementation = file.read()
+_expected_receiver_header_file_name = 'Messages-expected.h'
+_expected_legacy_receiver_header_file_name = 'LegacyMessages-expected.h'
+_expected_superclass_receiver_header_file_name = 'MessagesSuperclass-expected.h'
-with open(os.path.join(script_directory, 'LegacyMessageReceiver-expected.cpp')) as file:
- _expected_legacy_receiver_implementation = file.read()
-
-with open(os.path.join(script_directory, 'MessageReceiverSuperclass-expected.cpp')) as file:
- _expected_superclass_receiver_implementation = file.read()
+_expected_receiver_implementation_file_name = 'MessageReceiver-expected.cpp'
+_expected_legacy_receiver_implementation_file_name = 'LegacyMessageReceiver-expected.cpp'
+_expected_superclass_receiver_implementation_file_name = 'MessageReceiverSuperclass-expected.cpp'
_expected_results = {
'name': 'WebPage',
@@ -243,7 +232,7 @@ _expected_results = {
_expected_superclass_results = {
'name': 'WebPage',
- 'superclass' : 'WebPageBase',
+ 'superclass': 'WebPageBase',
'conditions': None,
'messages': (
{
@@ -278,7 +267,7 @@ class ParsingTest(MessagesTest):
self.assertTrue(parameter.has_attribute(attribute))
else:
self.assertEquals(parameter.attributes, frozenset())
- if message.reply_parameters != None:
+ if message.reply_parameters is not None:
for index, parameter in enumerate(message.reply_parameters):
self.assertEquals(parameter.type, expected_message['reply_parameters'][index][0])
self.assertEquals(parameter.name, expected_message['reply_parameters'][index][1])
@@ -307,40 +296,50 @@ class ParsingTest(MessagesTest):
self.check_message(message, _expected_superclass_results['messages'][index])
-
class GeneratedFileContentsTest(unittest.TestCase):
- def assertGeneratedFileContentsEqual(self, first, second):
- first_list = first.split('\n')
- second_list = second.split('\n')
+ def assertGeneratedFileContentsEqual(self, actual_file_contents, expected_file_name):
+ if reset_results:
+ with open(os.path.join(script_directory, expected_file_name), mode='w') as out_file:
+ out_file.write(actual_file_contents)
+ return
- for index, first_line in enumerate(first_list):
- self.assertEquals(first_line, second_list[index])
+ with open(os.path.join(script_directory, expected_file_name), mode='r') as in_file:
+ expected_file_contents = in_file.read()
+ actual_line_list = actual_file_contents.splitlines(False)
+ expected_line_list = expected_file_contents.splitlines(False)
- self.assertEquals(len(first_list), len(second_list))
+ for index, actual_line in enumerate(actual_line_list):
+ self.assertEquals(actual_line, expected_line_list[index])
+ self.assertEquals(len(actual_line_list), len(expected_line_list))
-class HeaderTest(GeneratedFileContentsTest):
- def test_header(self):
- file_contents = messages.generate_messages_header(StringIO(_messages_file_contents))
- self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_header)
+ def assertHeaderEqual(self, input_messages_file_contents, expected_file_name):
+ actual_file_contents = messages.generate_messages_header(StringIO(input_messages_file_contents))
+ self.assertGeneratedFileContentsEqual(actual_file_contents, expected_file_name)
- legacy_file_contents = messages.generate_messages_header(StringIO(_legacy_messages_file_contents))
- self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_header)
+ def assertImplementationEqual(self, input_messages_file_contents, expected_file_name):
+ actual_file_contents = messages.generate_message_handler(StringIO(input_messages_file_contents))
+ self.assertGeneratedFileContentsEqual(actual_file_contents, expected_file_name)
- superclass_file_contents = messages.generate_messages_header(StringIO(_superclass_messages_file_contents))
- self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_header)
+class HeaderTest(GeneratedFileContentsTest):
+ def test_receiver_headers(self):
+ self.assertHeaderEqual(_messages_file_contents,
+ _expected_receiver_header_file_name)
+ self.assertHeaderEqual(_legacy_messages_file_contents,
+ _expected_legacy_receiver_header_file_name)
+ self.assertHeaderEqual(_superclass_messages_file_contents,
+ _expected_superclass_receiver_header_file_name)
-class ReceiverImplementationTest(GeneratedFileContentsTest):
- def test_receiver_implementation(self):
- file_contents = messages.generate_message_handler(StringIO(_messages_file_contents))
- self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_implementation)
-
- legacy_file_contents = messages.generate_message_handler(StringIO(_legacy_messages_file_contents))
- self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_implementation)
- superclass_file_contents = messages.generate_message_handler(StringIO(_superclass_messages_file_contents))
- self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_implementation)
+class ReceiverImplementationTest(GeneratedFileContentsTest):
+ def test_receiver_implementations(self):
+ self.assertImplementationEqual(_messages_file_contents,
+ _expected_receiver_implementation_file_name)
+ self.assertImplementationEqual(_legacy_messages_file_contents,
+ _expected_legacy_receiver_implementation_file_name)
+ self.assertImplementationEqual(_superclass_messages_file_contents,
+ _expected_superclass_receiver_implementation_file_name)
class UnsupportedPrecompilerDirectiveTest(unittest.TestCase):
@@ -353,5 +352,38 @@ class UnsupportedPrecompilerDirectiveTest(unittest.TestCase):
messages.generate_message_handler(StringIO("asd\n#elif bla\nfoo"))
+def add_reset_results_to_unittest_help():
+ script_name = os.path.basename(__file__)
+ reset_results_help = '''
+Custom Options:
+ -r, --reset-results Reset expected results for {0}
+'''.format(script_name)
+
+ options_regex = re.compile('^Usage:')
+ lines = unittest.TestProgram.USAGE.splitlines(True)
+ index = 0
+ for index, line in enumerate(lines):
+ if options_regex.match(line) and index + 1 < len(lines):
+ lines.insert(index + 1, reset_results_help)
+ break
+
+ if index == (len(lines) - 1):
+ lines.append(reset_results_help)
+
+ unittest.TestProgram.USAGE = ''.join(lines)
+
+
+def parse_sys_argv():
+ global reset_results
+ for index, arg in enumerate(sys.argv[1:]):
+ if arg in ('-r', '--r', '--reset', '--reset-results') or '--reset-results'.startswith(arg):
+ reset_results = True
+ del sys.argv[index + 1]
+ break
+
+
if __name__ == '__main__':
+ reset_results = False
+ add_reset_results_to_unittest_help()
+ parse_sys_argv()
unittest.main()
diff --git a/Source/WebKit2/Scripts/webkit/model.py b/Source/WebKit2/Scripts/webkit/model.py
index ebf75ccd4..d0830440d 100644
--- a/Source/WebKit2/Scripts/webkit/model.py
+++ b/Source/WebKit2/Scripts/webkit/model.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -38,6 +38,7 @@ class MessageReceiver(object):
def has_attribute(self, attribute):
return attribute in self.attributes
+
class Message(object):
def __init__(self, name, parameters, reply_parameters, attributes, condition):
self.name = name
diff --git a/Source/WebKit2/Scripts/webkit/parser.py b/Source/WebKit2/Scripts/webkit/parser.py
index 69a81dfef..306139468 100644
--- a/Source/WebKit2/Scripts/webkit/parser.py
+++ b/Source/WebKit2/Scripts/webkit/parser.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -121,6 +121,7 @@ def split_parameters_string(parameters_string):
parameters.append(current_parameter_string)
return parameters
+
def parse_parameters_string(parameters_string):
parameters = []
diff --git a/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp b/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp
index 2db152766..85dc2a5ca 100644
--- a/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp
+++ b/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp
@@ -45,7 +45,7 @@ bool ChildProcessMainBase::parseCommandLine(int argc, char** argv)
if (argc < 2)
return false;
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
QByteArray serviceName(argv[1]);
// Get the server port.
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index b894d7338..7e4b37012 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -385,8 +385,10 @@ void QQuickWebViewPrivate::initialize(WKPageConfigurationRef configurationRef)
loadClient.didChangeProgress = didChangeProgress;
loadClient.didFinishProgress = didFinishProgress;
loadClient.didChangeBackForwardList = didChangeBackForwardList;
+ // FIXME: These three functions should not be part of this client.
loadClient.processDidBecomeUnresponsive = processDidBecomeUnresponsive;
loadClient.processDidBecomeResponsive = processDidBecomeResponsive;
+ loadClient.processDidCrash = processDidCrash;
WKPageSetPageLoaderClient(webPage.get(), &loadClient.base);
}
@@ -605,20 +607,21 @@ void QQuickWebViewPrivate::didRenderFrame()
}
}
-void QQuickWebViewPrivate::processDidCrash()
+void QQuickWebViewPrivate::processDidCrash(WKPageRef, const void* clientInfo)
{
- Q_Q(QQuickWebView);
+ QQuickWebViewPrivate* d = toQQuickWebViewPrivate(clientInfo);
+ QQuickWebView* q = d->q_ptr;
- QUrl url(URL(WebCore::ParsedURLString, webPageProxy->urlAtProcessExit()));
+ QUrl url(URL(WebCore::ParsedURLString, d->webPageProxy->urlAtProcessExit()));
qWarning("WARNING: The web process experienced a crash on '%s'.", qPrintable(url.toString(QUrl::RemoveUserInfo)));
- pageEventHandler->resetGestureRecognizers();
+ d->pageEventHandler->resetGestureRecognizers();
// Check if loading was ongoing, when process crashed.
- if (m_loadProgress > 0 && m_loadProgress < 100) {
+ if (d->m_loadProgress > 0 && d->m_loadProgress < 100) {
QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QStringLiteral("The web process crashed."), QQuickWebView::InternalErrorDomain, 0);
- loadProgressDidChange(100);
+ d->loadProgressDidChange(100);
emit q->loadingChanged(&loadRequest);
}
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
index cca489582..dba68e792 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
@@ -128,7 +128,6 @@ public:
// PageClient.
WebCore::IntSize viewSize() const;
virtual void pageDidRequestScroll(const QPoint& pos) { }
- void processDidCrash();
void didRelaunchProcess();
std::unique_ptr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
void handleDownloadRequest(WebKit::DownloadProxy*);
@@ -176,6 +175,7 @@ protected:
static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo);
static void processDidBecomeUnresponsive(WKPageRef, const void* clientInfo);
static void processDidBecomeResponsive(WKPageRef, const void* clientInfo);
+ static void processDidCrash(WKPageRef, const void* clientInfo);
QQuickWebViewPrivate(QQuickWebView* viewport);
RefPtr<WebKit::WebPageProxy> webPageProxy;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
index c781a97ca..82a3db952 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
@@ -83,6 +83,10 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute
return WKPreferencesGetUniversalAccessFromFileURLsAllowed(preferencesRef);
case FileAccessFromFileURLsAllowed:
return WKPreferencesGetFileAccessFromFileURLsAllowed(preferencesRef);
+ case LogsPageMessagesToSystemConsoleEnabled:
+ return WKPreferencesGetLogsPageMessagesToSystemConsoleEnabled(preferencesRef);
+ case WebSecurityEnabled:
+ return WKPreferencesGetWebSecurityEnabled(preferencesRef);
default:
ASSERT_NOT_REACHED();
return false;
@@ -156,6 +160,12 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a
case FileAccessFromFileURLsAllowed:
WKPreferencesSetFileAccessFromFileURLsAllowed(preferencesRef, enable);
break;
+ case LogsPageMessagesToSystemConsoleEnabled:
+ WKPreferencesSetLogsPageMessagesToSystemConsoleEnabled(preferencesRef, enable);
+ break;
+ case WebSecurityEnabled:
+ WKPreferencesSetWebSecurityEnabled(preferencesRef, enable);
+ break;
default:
ASSERT_NOT_REACHED();
}
@@ -631,6 +641,32 @@ void QWebPreferences::setLinksIncludedInFocusChain(bool enable)
emit linksIncludedInFocusChainChanged();
}
+bool QWebPreferences::logsPageMessagesToSystemConsoleEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::LogsPageMessagesToSystemConsoleEnabled);
+}
+
+void QWebPreferences::setLogsPageMessagesToSystemConsoleEnabled(bool enable)
+{
+ if (logsPageMessagesToSystemConsoleEnabled() == enable)
+ return;
+ d->setAttribute(QWebPreferencesPrivate::LogsPageMessagesToSystemConsoleEnabled, enable);
+ emit logsPageMessagesToSystemConsoleEnabledChanged();
+}
+
+bool QWebPreferences::webSecurityEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::WebSecurityEnabled);
+}
+
+void QWebPreferences::setWebSecurityEnabled(bool enable)
+{
+ if (webSecurityEnabled() == enable)
+ return;
+ d->setAttribute(QWebPreferencesPrivate::WebSecurityEnabled, enable);
+ emit webSecurityEnabledChanged();
+}
+
QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences)
{
return preferences->d;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
index 08c4df2d8..702146c38 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
@@ -51,6 +51,8 @@ public:
Q_PROPERTY(bool fileAccessFromFileURLsAllowed READ fileAccessFromFileURLsAllowed WRITE setFileAccessFromFileURLsAllowed NOTIFY fileAccessFromFileURLsAllowedChanged FINAL)
Q_PROPERTY(bool spatialNavigationEnabled READ spatialNavigationEnabled WRITE setSpatialNavigationEnabled NOTIFY spatialNavigationEnabledChanged FINAL)
Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain NOTIFY linksIncludedInFocusChainChanged FINAL)
+ Q_PROPERTY(bool logsPageMessagesToSystemConsoleEnabled READ logsPageMessagesToSystemConsoleEnabled WRITE setLogsPageMessagesToSystemConsoleEnabled NOTIFY logsPageMessagesToSystemConsoleEnabledChanged FINAL)
+ Q_PROPERTY(bool webSecurityEnabled READ webSecurityEnabled WRITE setWebSecurityEnabled NOTIFY webSecurityEnabledChanged FINAL)
Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL)
@@ -123,6 +125,12 @@ public:
bool linksIncludedInFocusChain() const;
void setLinksIncludedInFocusChain(bool enable);
+ bool logsPageMessagesToSystemConsoleEnabled() const;
+ void setLogsPageMessagesToSystemConsoleEnabled(bool);
+
+ bool webSecurityEnabled() const;
+ void setWebSecurityEnabled(bool);
+
QString standardFontFamily() const;
void setStandardFontFamily(const QString& family);
@@ -171,6 +179,8 @@ Q_SIGNALS:
void linksIncludedInFocusChainChanged();
void universalAccessFromFileURLsAllowedChanged();
void fileAccessFromFileURLsAllowedChanged();
+ void logsPageMessagesToSystemConsoleEnabledChanged();
+ void webSecurityEnabledChanged();
void standardFontFamilyChanged();
void fixedFontFamilyChanged();
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
index 2b4c804ff..a5395c3c8 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
@@ -44,7 +44,9 @@ public:
UniversalAccessFromFileURLsAllowed,
FileAccessFromFileURLsAllowed,
SpatialNavigationEnabled,
- LinksIncludedInFocusChain
+ LinksIncludedInFocusChain,
+ LogsPageMessagesToSystemConsoleEnabled,
+ WebSecurityEnabled
};
enum FontFamily {
diff --git a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
index e62e18d03..f5b66cd5f 100644
--- a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
+++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
@@ -58,8 +58,7 @@ void ProcessLauncher::didFinishLaunchingProcess(PlatformProcessIdentifier proces
if (!m_client) {
// FIXME: Make Identifier a move-only object and release port rights/connections in the destructor.
-#if OS(DARWIN) && !PLATFORM(GTK)
- // FIXME: Should really be something like USE(MACH)
+#if USE(MACH_PORTS)
if (identifier.port)
mach_port_mod_refs(mach_task_self(), identifier.port, MACH_PORT_RIGHT_RECEIVE, -1);
#endif
diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
index 51a3ffbba..694a759e6 100644
--- a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
+++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -62,7 +62,7 @@
#include <QCoreApplication>
#endif
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
#include <mach/mach_init.h>
#include <servers/bootstrap.h>
@@ -70,7 +70,7 @@ extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, u
#endif
// for QNX we need SOCK_DGRAM, see https://bugs.webkit.org/show_bug.cgi?id=95553
-#if defined(SOCK_SEQPACKET) && !defined(Q_OS_MACX) && !OS(QNX)
+#if defined(SOCK_SEQPACKET) && !defined(Q_OS_MACOS) && !OS(QNX)
#define SOCKET_TYPE SOCK_SEQPACKET
#else
#define SOCKET_TYPE SOCK_DGRAM
@@ -101,7 +101,7 @@ void QtWebProcess::setupChildProcess()
#endif
prctl(PR_SET_PDEATHSIG, SIGKILL);
#endif
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_MACOS)
qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", QByteArray("1"));
#endif
}
@@ -126,7 +126,7 @@ void ProcessLauncher::launchProcess()
#if ENABLE(DATABASE_PROCESS)
} else if (m_launchOptions.processType == ProcessType::Database) {
commandLine = QLatin1String("%1 \"%2\" %3 %4");
- QByteArray processPrefix = qgetenv("QT_WEBKIT2_DP_CMD_PREFIX");
+ QByteArray processPrefix = qgetenv("QT_WEBKIT2_SP_CMD_PREFIX");
commandLine = commandLine.arg(QLatin1String(processPrefix.constData())).arg(QString(executablePathOfDatabaseProcess()));
#endif
} else {
@@ -134,7 +134,7 @@ void ProcessLauncher::launchProcess()
ASSERT_NOT_REACHED();
}
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
// Create the listening port.
mach_port_t connector;
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &connector);
@@ -216,7 +216,7 @@ void ProcessLauncher::launchProcess()
if (!webProcessOrSUIDHelper->waitForStarted()) {
qDebug() << "Failed to start" << commandLine;
ASSERT_NOT_REACHED();
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
mach_port_deallocate(mach_task_self(), connector);
mach_port_mod_refs(mach_task_self(), connector, MACH_PORT_RIGHT_RECEIVE, -1);
#endif
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp
index 5f6a16f70..d0ff9bca5 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -6287,7 +6287,7 @@ void WebPageProxy::setURLSchemeHandlerForScheme(Ref<WebURLSchemeHandler>&& handl
WebURLSchemeHandler* WebPageProxy::urlSchemeHandlerForScheme(const String& scheme)
{
- return m_urlSchemeHandlersByScheme.get(scheme);
+ return scheme.isNull() ? nullptr : m_urlSchemeHandlersByScheme.get(scheme);
}
void WebPageProxy::startURLSchemeHandlerTask(uint64_t handlerIdentifier, uint64_t resourceIdentifier, const WebCore::ResourceRequest& request)
diff --git a/Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h b/Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h
new file mode 100644
index 000000000..0af685b61
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ColorChooserContextObject.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include <QColor>
+#include <QObject>
+#include <QRectF>
+
+namespace WebKit {
+
+class ColorChooserContextObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QColor currentColor READ currentColor CONSTANT FINAL)
+ Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
+
+public:
+ ColorChooserContextObject(const QColor& color, const QRectF& rect)
+ : m_currentColor(color)
+ , m_rect(rect)
+ {
+ }
+
+ QColor currentColor() const { return m_currentColor; }
+ QRectF elementRect() const { return m_rect; }
+
+ Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); }
+ Q_INVOKABLE void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(const QColor&);
+ void rejected();
+
+private:
+ QColor m_currentColor;
+ QRectF m_rect;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/DialogContextObjects.h b/Source/WebKit2/UIProcess/qt/DialogContextObjects.h
new file mode 100644
index 000000000..c6257125e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/DialogContextObjects.h
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include "QtDialogRunner.h"
+#include "WKRetainPtr.h"
+#include "WKStringQt.h"
+#include "qtwebsecurityorigin_p.h"
+
+namespace WebKit {
+
+// All dialogs need a way to support the state of the
+// dialog being done/finished/dismissed. This is handled
+// in the dialog base context.
+class DialogContextBase : public QObject {
+ Q_OBJECT
+
+public:
+ DialogContextBase()
+ : QObject()
+ , m_dismissed(false)
+ {
+ }
+
+public Q_SLOTS:
+ // Allows clients to call dismiss() directly, while also
+ // being able to hook up signals to automatically also
+ // dismiss the dialog since it's a slot.
+
+ void dismiss()
+ {
+ m_dismissed = true;
+ emit dismissed();
+ }
+
+Q_SIGNALS:
+ void dismissed();
+
+private:
+ // We store the dismissed state so that run() can check to see if a
+ // dialog has already been dismissed before spinning an event loop.
+ bool m_dismissed;
+ friend void QtDialogRunner::run();
+};
+
+class DialogContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString message READ message CONSTANT)
+ Q_PROPERTY(QString defaultValue READ defaultValue CONSTANT)
+
+public:
+ DialogContextObject(const QString& message, const QString& defaultValue = QString())
+ : DialogContextBase()
+ , m_message(message)
+ , m_defaultValue(defaultValue)
+ {
+ connect(this, SIGNAL(accepted(QString)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+ QString message() const { return m_message; }
+ QString defaultValue() const { return m_defaultValue; }
+
+public Q_SLOTS:
+ void accept(const QString& result = QString()) { emit accepted(result); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(const QString& result);
+ void rejected();
+
+private:
+ QString m_message;
+ QString m_defaultValue;
+};
+
+class BaseAuthenticationContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
+ Q_PROPERTY(QString prefilledUsername READ prefilledUsername CONSTANT)
+
+public:
+ BaseAuthenticationContextObject(const QString& hostname, const QString& prefilledUsername)
+ : DialogContextBase()
+ , m_hostname(hostname)
+ , m_prefilledUsername(prefilledUsername)
+ {
+ connect(this, SIGNAL(accepted(QString, QString)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QString hostname() const { return m_hostname; }
+ QString prefilledUsername() const { return m_prefilledUsername; }
+
+public Q_SLOTS:
+ void accept(const QString& username, const QString& password) { emit accepted(username, password); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(const QString& username, const QString& password);
+ void rejected();
+
+private:
+ QString m_hostname;
+ QString m_prefilledUsername;
+};
+
+class HttpAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
+ Q_OBJECT
+ Q_PROPERTY(QString realm READ realm CONSTANT)
+
+public:
+ HttpAuthenticationDialogContextObject(const QString& hostname, const QString& realm, const QString& prefilledUsername)
+ : BaseAuthenticationContextObject(hostname, prefilledUsername)
+ , m_realm(realm)
+ {
+ }
+
+ QString realm() const { return m_realm; }
+
+private:
+ QString m_realm;
+};
+
+class ProxyAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
+ Q_OBJECT
+ Q_PROPERTY(quint16 port READ port CONSTANT)
+
+public:
+ ProxyAuthenticationDialogContextObject(const QString& hostname, quint16 port, const QString& prefilledUsername)
+ : BaseAuthenticationContextObject(hostname, prefilledUsername)
+ , m_port(port)
+ {
+ }
+
+ quint16 port() const { return m_port; }
+
+private:
+ quint16 m_port;
+};
+
+class CertificateVerificationDialogContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
+
+public:
+ CertificateVerificationDialogContextObject(const QString& hostname)
+ : DialogContextBase()
+ , m_hostname(hostname)
+ {
+ connect(this, SIGNAL(accepted()), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QString hostname() const { return m_hostname; }
+
+public Q_SLOTS:
+ void accept() { emit accepted(); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted();
+ void rejected();
+
+private:
+ QString m_hostname;
+};
+
+class FilePickerContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QStringList fileList READ fileList CONSTANT)
+ Q_PROPERTY(bool allowMultipleFiles READ allowMultipleFiles CONSTANT)
+
+public:
+ FilePickerContextObject(const QStringList& selectedFiles, bool allowMultiple)
+ : DialogContextBase()
+ , m_allowMultiple(allowMultiple)
+ , m_fileList(selectedFiles)
+ {
+ connect(this, SIGNAL(fileSelected(QStringList)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QStringList fileList() const { return m_fileList; }
+ bool allowMultipleFiles() const { return m_allowMultiple;}
+
+public Q_SLOTS:
+ void reject() { emit rejected();}
+ void accept(const QVariant& path)
+ {
+ QStringList filesPath = path.toStringList();
+
+ if (filesPath.isEmpty()) {
+ emit rejected();
+ return;
+ }
+
+ // For single file upload, send only the first element if there are more than one file paths
+ if (!m_allowMultiple && filesPath.count() > 1)
+ filesPath = QStringList(filesPath.at(0));
+ emit fileSelected(filesPath);
+ }
+
+Q_SIGNALS:
+ void rejected();
+ void fileSelected(const QStringList&);
+
+private:
+ bool m_allowMultiple;
+ QStringList m_fileList;
+};
+
+class DatabaseQuotaDialogContextObject : public DialogContextBase {
+ Q_OBJECT
+ Q_PROPERTY(QString databaseName READ databaseName CONSTANT)
+ Q_PROPERTY(QString displayName READ displayName CONSTANT)
+ Q_PROPERTY(quint64 currentQuota READ currentQuota CONSTANT)
+ Q_PROPERTY(quint64 currentOriginUsage READ currentOriginUsage CONSTANT)
+ Q_PROPERTY(quint64 currentDatabaseUsage READ currentDatabaseUsage CONSTANT)
+ Q_PROPERTY(quint64 expectedUsage READ expectedUsage CONSTANT)
+ Q_PROPERTY(QtWebSecurityOrigin* origin READ securityOrigin CONSTANT)
+
+public:
+ DatabaseQuotaDialogContextObject(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage)
+ : DialogContextBase()
+ , m_databaseName(databaseName)
+ , m_displayName(displayName)
+ , m_currentQuota(currentQuota)
+ , m_currentOriginUsage(currentOriginUsage)
+ , m_currentDatabaseUsage(currentDatabaseUsage)
+ , m_expectedUsage(expectedUsage)
+ {
+ WKRetainPtr<WKStringRef> scheme = adoptWK(WKSecurityOriginCopyProtocol(securityOrigin));
+ WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(securityOrigin));
+
+ m_securityOrigin.setScheme(WKStringCopyQString(scheme.get()));
+ m_securityOrigin.setHost(WKStringCopyQString(host.get()));
+ m_securityOrigin.setPort(static_cast<int>(WKSecurityOriginGetPort(securityOrigin)));
+
+ connect(this, SIGNAL(accepted(quint64)), SLOT(dismiss()));
+ connect(this, SIGNAL(rejected()), SLOT(dismiss()));
+ }
+
+ QString databaseName() const { return m_databaseName; }
+ QString displayName() const { return m_displayName; }
+ quint64 currentQuota() const { return m_currentQuota; }
+ quint64 currentOriginUsage() const { return m_currentOriginUsage; }
+ quint64 currentDatabaseUsage() const { return m_currentDatabaseUsage; }
+ quint64 expectedUsage() const { return m_expectedUsage; }
+ QtWebSecurityOrigin* securityOrigin() { return &m_securityOrigin; }
+
+public Q_SLOTS:
+ void accept(quint64 size) { emit accepted(size); }
+ void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void accepted(quint64 size);
+ void rejected();
+
+private:
+ QString m_databaseName;
+ QString m_displayName;
+ quint64 m_currentQuota;
+ quint64 m_currentOriginUsage;
+ quint64 m_currentDatabaseUsage;
+ quint64 m_expectedUsage;
+ QtWebSecurityOrigin m_securityOrigin;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp
new file mode 100644
index 000000000..a78fe4964
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ItemSelectorContextObject.h"
+
+#include "PlatformPopupMenuData.h"
+#include "WebPopupItem.h"
+#include "WebPopupMenuProxyQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <QtCore/QAbstractListModel>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ItemSelectorContextObject::ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>& webPopupItems, bool multiple)
+ : m_elementRect(elementRect)
+ , m_items(webPopupItems, multiple)
+{
+ connect(&m_items, SIGNAL(indexUpdated()), SLOT(onIndexUpdate()));
+}
+
+void ItemSelectorContextObject::onIndexUpdate()
+{
+ // Send the update for multi-select list.
+ if (m_items.multiple())
+ emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
+}
+
+
+void ItemSelectorContextObject::accept(int index)
+{
+ // If the index is not valid for multi-select lists, just hide the pop up as the selected indices have
+ // already been sent.
+ if ((index == -1) && m_items.multiple())
+ emit done();
+ else {
+ if (index != -1)
+ m_items.toggleItem(index);
+ emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
+ }
+}
+
+static QHash<int, QByteArray> createRoleNamesHash()
+{
+ QHash<int, QByteArray> roles;
+ roles[Qt::DisplayRole] = "text";
+ roles[Qt::ToolTipRole] = "tooltip";
+ roles[PopupMenuItemModel::GroupRole] = "group";
+ roles[PopupMenuItemModel::EnabledRole] = "enabled";
+ roles[PopupMenuItemModel::SelectedRole] = "selected";
+ roles[PopupMenuItemModel::IsSeparatorRole] = "isSeparator";
+ return roles;
+}
+
+PopupMenuItemModel::PopupMenuItemModel(const Vector<WebPopupItem>& webPopupItems, bool multiple)
+ : m_selectedModelIndex(-1)
+ , m_allowMultiples(multiple)
+{
+ buildItems(webPopupItems);
+}
+
+QHash<int, QByteArray> PopupMenuItemModel::roleNames() const
+{
+ static QHash<int, QByteArray> roles = createRoleNamesHash();
+ return roles;
+}
+
+QVariant PopupMenuItemModel::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid() || index.row() < 0 || index.row() >= m_items.size())
+ return QVariant();
+
+ const Item& item = m_items[index.row()];
+ if (item.isSeparator) {
+ if (role == IsSeparatorRole)
+ return true;
+ return QVariant();
+ }
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return item.text;
+ case Qt::ToolTipRole:
+ return item.toolTip;
+ case GroupRole:
+ return item.group;
+ case EnabledRole:
+ return item.enabled;
+ case SelectedRole:
+ return item.selected;
+ case IsSeparatorRole:
+ return false;
+ }
+
+ return QVariant();
+}
+
+void PopupMenuItemModel::select(int index)
+{
+ toggleItem(index);
+ emit indexUpdated();
+}
+
+void PopupMenuItemModel::toggleItem(int index)
+{
+ int oldIndex = m_selectedModelIndex;
+ if (index < 0 || index >= m_items.size())
+ return;
+ Item& item = m_items[index];
+ if (!item.enabled)
+ return;
+
+ m_selectedModelIndex = index;
+ if (m_allowMultiples)
+ item.selected = !item.selected;
+ else {
+ if (index == oldIndex)
+ return;
+ item.selected = true;
+ if (oldIndex != -1) {
+ Item& oldItem = m_items[oldIndex];
+ oldItem.selected = false;
+ emit dataChanged(this->index(oldIndex), this->index(oldIndex));
+ }
+ }
+
+ emit dataChanged(this->index(index), this->index(index));
+}
+
+int PopupMenuItemModel::selectedOriginalIndex() const
+{
+ if (m_selectedModelIndex == -1)
+ return -1;
+ return m_items[m_selectedModelIndex].originalIndex;
+}
+
+void PopupMenuItemModel::buildItems(const Vector<WebPopupItem>& webPopupItems)
+{
+ QString currentGroup;
+ m_items.reserveInitialCapacity(webPopupItems.size());
+ for (int i = 0; i < webPopupItems.size(); i++) {
+ const WebPopupItem& webPopupItem = webPopupItems[i];
+ if (webPopupItem.m_isLabel) {
+ currentGroup = webPopupItem.m_text;
+ continue;
+ }
+ if (webPopupItem.m_isSelected && !m_allowMultiples)
+ m_selectedModelIndex = m_items.size();
+ m_items.append(Item(webPopupItem, currentGroup, i));
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h
new file mode 100644
index 000000000..ad63893d6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ItemSelectorContextObject.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "WebPopupItem.h"
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QRectF>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class PopupMenuItemModel final : public QAbstractListModel {
+ Q_OBJECT
+
+public:
+ enum Roles {
+ GroupRole = Qt::UserRole,
+ EnabledRole = Qt::UserRole + 1,
+ SelectedRole = Qt::UserRole + 2,
+ IsSeparatorRole = Qt::UserRole + 3
+ };
+
+ PopupMenuItemModel(const Vector<WebPopupItem>&, bool multiple);
+ int rowCount(const QModelIndex& parent = QModelIndex()) const final { return m_items.size(); }
+ QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const final;
+ QHash<int, QByteArray> roleNames() const final;
+
+ Q_INVOKABLE void select(int);
+
+ int selectedOriginalIndex() const;
+ bool multiple() const { return m_allowMultiples; }
+ void toggleItem(int);
+
+Q_SIGNALS:
+ void indexUpdated();
+
+private:
+ struct Item {
+ Item(const WebPopupItem& webPopupItem, const QString& group, int originalIndex)
+ : text(webPopupItem.m_text)
+ , toolTip(webPopupItem.m_toolTip)
+ , group(group)
+ , originalIndex(originalIndex)
+ , enabled(webPopupItem.m_isEnabled)
+ , selected(webPopupItem.m_isSelected)
+ , isSeparator(webPopupItem.m_type == WebPopupItem::Separator)
+ { }
+
+ QString text;
+ QString toolTip;
+ QString group;
+ // Keep track of originalIndex because we don't add the label (group) items to our vector.
+ int originalIndex;
+ bool enabled;
+ bool selected;
+ bool isSeparator;
+ };
+
+ void buildItems(const Vector<WebPopupItem>& webPopupItems);
+
+ Vector<Item> m_items;
+ int m_selectedModelIndex;
+ bool m_allowMultiples;
+};
+
+class ItemSelectorContextObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
+ Q_PROPERTY(QObject* items READ items CONSTANT FINAL)
+ Q_PROPERTY(bool allowMultiSelect READ allowMultiSelect CONSTANT FINAL)
+
+public:
+ ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>&, bool multiple);
+
+ QRectF elementRect() const { return m_elementRect; }
+ PopupMenuItemModel* items() { return &m_items; }
+ bool allowMultiSelect() { return m_items.multiple(); }
+
+ Q_INVOKABLE void accept(int index = -1);
+ Q_INVOKABLE void reject() { emit done(); }
+ Q_INVOKABLE void dismiss() { emit done(); }
+
+Q_SIGNALS:
+ void acceptedWithOriginalIndex(int);
+ void done();
+
+private Q_SLOTS:
+ void onIndexUpdate();
+
+private:
+ QRectF m_elementRect;
+ PopupMenuItemModel m_items;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
index 5043a170f..2cd5828a8 100644
--- a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
@@ -21,8 +21,7 @@
#include "config.h"
#include "QtDialogRunner.h"
-#include "WKRetainPtr.h"
-#include "WKStringQt.h"
+#include "DialogContextObjects.h"
#include "qquickwebview_p_p.h"
#include "qwebpermissionrequest_p.h"
#include <QtQml/QQmlComponent>
@@ -43,263 +42,6 @@ QtDialogRunner::~QtDialogRunner()
{
}
-// All dialogs need a way to support the state of the
-// dialog being done/finished/dismissed. This is handled
-// in the dialog base context.
-class DialogContextBase : public QObject {
- Q_OBJECT
-
-public:
- DialogContextBase()
- : QObject()
- , m_dismissed(false)
- {
- }
-
-public Q_SLOTS:
- // Allows clients to call dismiss() directly, while also
- // being able to hook up signals to automatically also
- // dismiss the dialog since it's a slot.
-
- void dismiss()
- {
- m_dismissed = true;
- emit dismissed();
- }
-
-Q_SIGNALS:
- void dismissed();
-
-private:
- // We store the dismissed state so that run() can check to see if a
- // dialog has already been dismissed before spinning an event loop.
- bool m_dismissed;
- friend void QtDialogRunner::run();
-};
-
-class DialogContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString message READ message CONSTANT)
- Q_PROPERTY(QString defaultValue READ defaultValue CONSTANT)
-
-public:
- DialogContextObject(const QString& message, const QString& defaultValue = QString())
- : DialogContextBase()
- , m_message(message)
- , m_defaultValue(defaultValue)
- {
- connect(this, SIGNAL(accepted(QString)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
- QString message() const { return m_message; }
- QString defaultValue() const { return m_defaultValue; }
-
-public Q_SLOTS:
- void accept(const QString& result = QString()) { emit accepted(result); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(const QString& result);
- void rejected();
-
-private:
- QString m_message;
- QString m_defaultValue;
-};
-
-class BaseAuthenticationContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString hostname READ hostname CONSTANT)
- Q_PROPERTY(QString prefilledUsername READ prefilledUsername CONSTANT)
-
-public:
- BaseAuthenticationContextObject(const QString& hostname, const QString& prefilledUsername)
- : DialogContextBase()
- , m_hostname(hostname)
- , m_prefilledUsername(prefilledUsername)
- {
- connect(this, SIGNAL(accepted(QString, QString)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QString hostname() const { return m_hostname; }
- QString prefilledUsername() const { return m_prefilledUsername; }
-
-public Q_SLOTS:
- void accept(const QString& username, const QString& password) { emit accepted(username, password); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(const QString& username, const QString& password);
- void rejected();
-
-private:
- QString m_hostname;
- QString m_prefilledUsername;
-};
-
-class HttpAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
- Q_OBJECT
- Q_PROPERTY(QString realm READ realm CONSTANT)
-
-public:
- HttpAuthenticationDialogContextObject(const QString& hostname, const QString& realm, const QString& prefilledUsername)
- : BaseAuthenticationContextObject(hostname, prefilledUsername)
- , m_realm(realm)
- {
- }
-
- QString realm() const { return m_realm; }
-
-private:
- QString m_realm;
-};
-
-class ProxyAuthenticationDialogContextObject : public BaseAuthenticationContextObject {
- Q_OBJECT
- Q_PROPERTY(quint16 port READ port CONSTANT)
-
-public:
- ProxyAuthenticationDialogContextObject(const QString& hostname, quint16 port, const QString& prefilledUsername)
- : BaseAuthenticationContextObject(hostname, prefilledUsername)
- , m_port(port)
- {
- }
-
- quint16 port() const { return m_port; }
-
-private:
- quint16 m_port;
-};
-
-class CertificateVerificationDialogContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString hostname READ hostname CONSTANT)
-
-public:
- CertificateVerificationDialogContextObject(const QString& hostname)
- : DialogContextBase()
- , m_hostname(hostname)
- {
- connect(this, SIGNAL(accepted()), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QString hostname() const { return m_hostname; }
-
-public Q_SLOTS:
- void accept() { emit accepted(); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted();
- void rejected();
-
-private:
- QString m_hostname;
-};
-
-class FilePickerContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QStringList fileList READ fileList CONSTANT)
- Q_PROPERTY(bool allowMultipleFiles READ allowMultipleFiles CONSTANT)
-
-public:
- FilePickerContextObject(const QStringList& selectedFiles, bool allowMultiple)
- : DialogContextBase()
- , m_allowMultiple(allowMultiple)
- , m_fileList(selectedFiles)
- {
- connect(this, SIGNAL(fileSelected(QStringList)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QStringList fileList() const { return m_fileList; }
- bool allowMultipleFiles() const { return m_allowMultiple;}
-
-public Q_SLOTS:
- void reject() { emit rejected();}
- void accept(const QVariant& path)
- {
- QStringList filesPath = path.toStringList();
-
- if (filesPath.isEmpty()) {
- emit rejected();
- return;
- }
-
- // For single file upload, send only the first element if there are more than one file paths
- if (!m_allowMultiple && filesPath.count() > 1)
- filesPath = QStringList(filesPath.at(0));
- emit fileSelected(filesPath);
- }
-
-Q_SIGNALS:
- void rejected();
- void fileSelected(const QStringList&);
-
-private:
- bool m_allowMultiple;
- QStringList m_fileList;
-};
-
-class DatabaseQuotaDialogContextObject : public DialogContextBase {
- Q_OBJECT
- Q_PROPERTY(QString databaseName READ databaseName CONSTANT)
- Q_PROPERTY(QString displayName READ displayName CONSTANT)
- Q_PROPERTY(quint64 currentQuota READ currentQuota CONSTANT)
- Q_PROPERTY(quint64 currentOriginUsage READ currentOriginUsage CONSTANT)
- Q_PROPERTY(quint64 currentDatabaseUsage READ currentDatabaseUsage CONSTANT)
- Q_PROPERTY(quint64 expectedUsage READ expectedUsage CONSTANT)
- Q_PROPERTY(QtWebSecurityOrigin* origin READ securityOrigin CONSTANT)
-
-public:
- DatabaseQuotaDialogContextObject(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage)
- : DialogContextBase()
- , m_databaseName(databaseName)
- , m_displayName(displayName)
- , m_currentQuota(currentQuota)
- , m_currentOriginUsage(currentOriginUsage)
- , m_currentDatabaseUsage(currentDatabaseUsage)
- , m_expectedUsage(expectedUsage)
- {
- WKRetainPtr<WKStringRef> scheme = adoptWK(WKSecurityOriginCopyProtocol(securityOrigin));
- WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(securityOrigin));
-
- m_securityOrigin.setScheme(WKStringCopyQString(scheme.get()));
- m_securityOrigin.setHost(WKStringCopyQString(host.get()));
- m_securityOrigin.setPort(static_cast<int>(WKSecurityOriginGetPort(securityOrigin)));
-
- connect(this, SIGNAL(accepted(quint64)), SLOT(dismiss()));
- connect(this, SIGNAL(rejected()), SLOT(dismiss()));
- }
-
- QString databaseName() const { return m_databaseName; }
- QString displayName() const { return m_displayName; }
- quint64 currentQuota() const { return m_currentQuota; }
- quint64 currentOriginUsage() const { return m_currentOriginUsage; }
- quint64 currentDatabaseUsage() const { return m_currentDatabaseUsage; }
- quint64 expectedUsage() const { return m_expectedUsage; }
- QtWebSecurityOrigin* securityOrigin() { return &m_securityOrigin; }
-
-public Q_SLOTS:
- void accept(quint64 size) { emit accepted(size); }
- void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(quint64 size);
- void rejected();
-
-private:
- QString m_databaseName;
- QString m_displayName;
- quint64 m_currentQuota;
- quint64 m_currentOriginUsage;
- quint64 m_currentDatabaseUsage;
- quint64 m_expectedUsage;
- QtWebSecurityOrigin m_securityOrigin;
-};
-
void QtDialogRunner::run()
{
DialogContextBase* context = static_cast<DialogContextBase*>(m_dialogContext->contextObject());
@@ -476,5 +218,5 @@ void QtDialogRunner::onDatabaseQuotaAccepted(quint64 quota)
} // namespace WebKit
-#include "QtDialogRunner.moc"
+#include "moc_DialogContextObjects.cpp"
#include "moc_QtDialogRunner.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
index 53faa7647..fd410ffdd 100644
--- a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
@@ -90,7 +90,8 @@ void QtPageClient::pageDidRequestScroll(const IntPoint& pos)
void QtPageClient::processDidExit()
{
- QQuickWebViewPrivate::get(m_webView)->processDidCrash();
+ // TODO: Do we need this signal?
+ // QQuickWebViewPrivate::get(m_webView)->processDidExit();
}
void QtPageClient::didRelaunchProcess()
diff --git a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp
index 031c32d9e..c37099654 100644
--- a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "WebColorPickerQt.h"
+#include "ColorChooserContextObject.h"
#include "qquickwebview_p.h"
#include "qquickwebview_p_p.h"
#include <QtQml/QQmlContext>
@@ -31,33 +32,6 @@ using namespace WebCore;
namespace WebKit {
-class ColorChooserContextObject : public QObject {
- Q_OBJECT
- Q_PROPERTY(QColor currentColor READ currentColor CONSTANT FINAL)
- Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
-
-public:
- ColorChooserContextObject(const QColor& color, const QRectF& rect)
- : m_currentColor(color)
- , m_rect(rect)
- {
- }
-
- QColor currentColor() const { return m_currentColor; }
- QRectF elementRect() const { return m_rect; }
-
- Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); }
- Q_INVOKABLE void reject() { emit rejected(); }
-
-Q_SIGNALS:
- void accepted(const QColor&);
- void rejected();
-
-private:
- QColor m_currentColor;
- QRectF m_rect;
-};
-
WebColorPickerQt::WebColorPickerQt(WebColorPicker::Client* client, QQuickWebView* webView, const Color& initialColor, const IntRect& elementRect)
: WebColorPicker(client)
, m_webView(webView)
@@ -149,5 +123,4 @@ void WebColorPickerQt::endPicker()
} // namespace WebKit
-#include "WebColorPickerQt.moc"
#include "moc_WebColorPickerQt.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
index 249de62ec..066e273a9 100644
--- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -27,6 +27,7 @@
#include "config.h"
#include "WebPopupMenuProxyQt.h"
+#include "ItemSelectorContextObject.h"
#include "PlatformPopupMenuData.h"
#include "WebPopupItem.h"
#include "qquickwebview_p.h"
@@ -39,229 +40,6 @@ using namespace WebCore;
namespace WebKit {
-static QHash<int, QByteArray> createRoleNamesHash();
-
-class PopupMenuItemModel final : public QAbstractListModel {
- Q_OBJECT
-
-public:
- enum Roles {
- GroupRole = Qt::UserRole,
- EnabledRole = Qt::UserRole + 1,
- SelectedRole = Qt::UserRole + 2,
- IsSeparatorRole = Qt::UserRole + 3
- };
-
- PopupMenuItemModel(const Vector<WebPopupItem>&, bool multiple);
- int rowCount(const QModelIndex& parent = QModelIndex()) const final { return m_items.size(); }
- QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const final;
- QHash<int, QByteArray> roleNames() const final;
-
- Q_INVOKABLE void select(int);
-
- int selectedOriginalIndex() const;
- bool multiple() const { return m_allowMultiples; }
- void toggleItem(int);
-
-Q_SIGNALS:
- void indexUpdated();
-
-private:
- struct Item {
- Item(const WebPopupItem& webPopupItem, const QString& group, int originalIndex)
- : text(webPopupItem.m_text)
- , toolTip(webPopupItem.m_toolTip)
- , group(group)
- , originalIndex(originalIndex)
- , enabled(webPopupItem.m_isEnabled)
- , selected(webPopupItem.m_isSelected)
- , isSeparator(webPopupItem.m_type == WebPopupItem::Separator)
- { }
-
- QString text;
- QString toolTip;
- QString group;
- // Keep track of originalIndex because we don't add the label (group) items to our vector.
- int originalIndex;
- bool enabled;
- bool selected;
- bool isSeparator;
- };
-
- void buildItems(const Vector<WebPopupItem>& webPopupItems);
-
- Vector<Item> m_items;
- int m_selectedModelIndex;
- bool m_allowMultiples;
-};
-
-class ItemSelectorContextObject : public QObject {
- Q_OBJECT
- Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
- Q_PROPERTY(QObject* items READ items CONSTANT FINAL)
- Q_PROPERTY(bool allowMultiSelect READ allowMultiSelect CONSTANT FINAL)
-
-public:
- ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>&, bool multiple);
-
- QRectF elementRect() const { return m_elementRect; }
- PopupMenuItemModel* items() { return &m_items; }
- bool allowMultiSelect() { return m_items.multiple(); }
-
- Q_INVOKABLE void accept(int index = -1);
- Q_INVOKABLE void reject() { emit done(); }
- Q_INVOKABLE void dismiss() { emit done(); }
-
-Q_SIGNALS:
- void acceptedWithOriginalIndex(int);
- void done();
-
-private Q_SLOTS:
- void onIndexUpdate();
-
-private:
- QRectF m_elementRect;
- PopupMenuItemModel m_items;
-};
-
-ItemSelectorContextObject::ItemSelectorContextObject(const QRectF& elementRect, const Vector<WebPopupItem>& webPopupItems, bool multiple)
- : m_elementRect(elementRect)
- , m_items(webPopupItems, multiple)
-{
- connect(&m_items, SIGNAL(indexUpdated()), SLOT(onIndexUpdate()));
-}
-
-void ItemSelectorContextObject::onIndexUpdate()
-{
- // Send the update for multi-select list.
- if (m_items.multiple())
- emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
-}
-
-
-void ItemSelectorContextObject::accept(int index)
-{
- // If the index is not valid for multi-select lists, just hide the pop up as the selected indices have
- // already been sent.
- if ((index == -1) && m_items.multiple())
- emit done();
- else {
- if (index != -1)
- m_items.toggleItem(index);
- emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex());
- }
-}
-
-static QHash<int, QByteArray> createRoleNamesHash()
-{
- QHash<int, QByteArray> roles;
- roles[Qt::DisplayRole] = "text";
- roles[Qt::ToolTipRole] = "tooltip";
- roles[PopupMenuItemModel::GroupRole] = "group";
- roles[PopupMenuItemModel::EnabledRole] = "enabled";
- roles[PopupMenuItemModel::SelectedRole] = "selected";
- roles[PopupMenuItemModel::IsSeparatorRole] = "isSeparator";
- return roles;
-}
-
-PopupMenuItemModel::PopupMenuItemModel(const Vector<WebPopupItem>& webPopupItems, bool multiple)
- : m_selectedModelIndex(-1)
- , m_allowMultiples(multiple)
-{
- buildItems(webPopupItems);
-}
-
-QHash<int, QByteArray> PopupMenuItemModel::roleNames() const
-{
- static QHash<int, QByteArray> roles = createRoleNamesHash();
- return roles;
-}
-
-QVariant PopupMenuItemModel::data(const QModelIndex& index, int role) const
-{
- if (!index.isValid() || index.row() < 0 || index.row() >= m_items.size())
- return QVariant();
-
- const Item& item = m_items[index.row()];
- if (item.isSeparator) {
- if (role == IsSeparatorRole)
- return true;
- return QVariant();
- }
-
- switch (role) {
- case Qt::DisplayRole:
- return item.text;
- case Qt::ToolTipRole:
- return item.toolTip;
- case GroupRole:
- return item.group;
- case EnabledRole:
- return item.enabled;
- case SelectedRole:
- return item.selected;
- case IsSeparatorRole:
- return false;
- }
-
- return QVariant();
-}
-
-void PopupMenuItemModel::select(int index)
-{
- toggleItem(index);
- emit indexUpdated();
-}
-
-void PopupMenuItemModel::toggleItem(int index)
-{
- int oldIndex = m_selectedModelIndex;
- if (index < 0 || index >= m_items.size())
- return;
- Item& item = m_items[index];
- if (!item.enabled)
- return;
-
- m_selectedModelIndex = index;
- if (m_allowMultiples)
- item.selected = !item.selected;
- else {
- if (index == oldIndex)
- return;
- item.selected = true;
- if (oldIndex != -1) {
- Item& oldItem = m_items[oldIndex];
- oldItem.selected = false;
- emit dataChanged(this->index(oldIndex), this->index(oldIndex));
- }
- }
-
- emit dataChanged(this->index(index), this->index(index));
-}
-
-int PopupMenuItemModel::selectedOriginalIndex() const
-{
- if (m_selectedModelIndex == -1)
- return -1;
- return m_items[m_selectedModelIndex].originalIndex;
-}
-
-void PopupMenuItemModel::buildItems(const Vector<WebPopupItem>& webPopupItems)
-{
- QString currentGroup;
- m_items.reserveInitialCapacity(webPopupItems.size());
- for (int i = 0; i < webPopupItems.size(); i++) {
- const WebPopupItem& webPopupItem = webPopupItems[i];
- if (webPopupItem.m_isLabel) {
- currentGroup = webPopupItem.m_text;
- continue;
- }
- if (webPopupItem.m_isSelected && !m_allowMultiples)
- m_selectedModelIndex = m_items.size();
- m_items.append(Item(webPopupItem, currentGroup, i));
- }
-}
-
WebPopupMenuProxyQt::WebPopupMenuProxyQt(WebPopupMenuProxy::Client& client, QQuickWebView* webView)
: WebPopupMenuProxy(client)
, m_webView(webView)
@@ -348,8 +126,5 @@ void WebPopupMenuProxyQt::createContext(QQmlComponent* component, QObject* conte
} // namespace WebKit
-// Since we define QObjects in WebPopupMenuProxyQt.cpp, this will trigger moc to run on .cpp.
-#include "WebPopupMenuProxyQt.moc"
-
// And we can't compile the moc for WebPopupMenuProxyQt.h by itself, since it doesn't include "config.h"
#include "moc_WebPopupMenuProxyQt.cpp"
diff --git a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp
index 2d0d7df10..ec271b5bd 100644
--- a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp
+++ b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp
@@ -45,7 +45,7 @@
#endif
#endif
-#if OS(DARWIN) && !USE(UNIX_DOMAIN_SOCKETS)
+#if USE(MACH_PORTS)
#include <servers/bootstrap.h>
extern "C" kern_return_t bootstrap_look_up2(mach_port_t, const name_t, mach_port_t*, pid_t, uint64_t);
@@ -139,7 +139,7 @@ Q_DECL_EXPORT int WebProcessMainQt(QGuiApplication* app)
return 1;
}
-#if OS(DARWIN)
+#if USE(MACH_PORTS)
QString serviceName = app->arguments().value(1);
// Get the server port.
diff --git a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
index d4864af5b..e687966db 100644
--- a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
+++ b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
@@ -39,7 +39,7 @@
#include <WebCore/RuntimeEnabledFeatures.h>
#include <wtf/RAMSize.h>
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_MACOS)
#include <dispatch/dispatch.h>
#include <mach/host_info.h>
#include <mach/mach.h>
@@ -99,7 +99,7 @@ void WebProcess::platformClearResourceCaches(ResourceCachesToClear)
{
}
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_MACOS)
static void parentProcessDiedCallback(void*)
{
QCoreApplication::quit();
@@ -134,7 +134,7 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
}
#endif
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_MACOS)
pid_t ppid = getppid();
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, ppid, DISPATCH_PROC_EXIT, queue);