2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "WebCoreArgumentCoders.h"
29 #include "ShareableBitmap.h"
30 #include <WebCore/AuthenticationChallenge.h>
31 #include <WebCore/Cookie.h>
32 #include <WebCore/Credential.h>
33 #include <WebCore/Cursor.h>
34 #include <WebCore/DatabaseDetails.h>
35 #include <WebCore/DictationAlternative.h>
36 #include <WebCore/DragSession.h>
37 #include <WebCore/Editor.h>
38 #include <WebCore/FileChooser.h>
39 #include <WebCore/GraphicsContext.h>
40 #include <WebCore/GraphicsLayer.h>
41 #include <WebCore/Image.h>
42 #include <WebCore/KURL.h>
43 #include <WebCore/PluginData.h>
44 #include <WebCore/ProtectionSpace.h>
45 #include <WebCore/ResourceError.h>
46 #include <WebCore/ResourceRequest.h>
47 #include <WebCore/ResourceResponse.h>
48 #include <WebCore/TextCheckerClient.h>
49 #include <WebCore/UserScript.h>
50 #include <WebCore/UserStyleSheet.h>
51 #include <WebCore/ViewportArguments.h>
52 #include <WebCore/WindowFeatures.h>
53 #include <wtf/text/StringHash.h>
55 using namespace WebCore;
56 using namespace WebKit;
60 void ArgumentCoder<AffineTransform>::encode(ArgumentEncoder& encoder, const AffineTransform& affineTransform)
62 SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
65 bool ArgumentCoder<AffineTransform>::decode(ArgumentDecoder* decoder, AffineTransform& affineTransform)
67 return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
71 void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint)
73 SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
76 bool ArgumentCoder<FloatPoint>::decode(ArgumentDecoder* decoder, FloatPoint& floatPoint)
78 return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
82 void ArgumentCoder<FloatRect>::encode(ArgumentEncoder& encoder, const FloatRect& floatRect)
84 SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
87 bool ArgumentCoder<FloatRect>::decode(ArgumentDecoder* decoder, FloatRect& floatRect)
89 return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
93 void ArgumentCoder<FloatSize>::encode(ArgumentEncoder& encoder, const FloatSize& floatSize)
95 SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
98 bool ArgumentCoder<FloatSize>::decode(ArgumentDecoder* decoder, FloatSize& floatSize)
100 return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
104 void ArgumentCoder<IntPoint>::encode(ArgumentEncoder& encoder, const IntPoint& intPoint)
106 SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
109 bool ArgumentCoder<IntPoint>::decode(ArgumentDecoder* decoder, IntPoint& intPoint)
111 return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
115 void ArgumentCoder<IntRect>::encode(ArgumentEncoder& encoder, const IntRect& intRect)
117 SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
120 bool ArgumentCoder<IntRect>::decode(ArgumentDecoder* decoder, IntRect& intRect)
122 return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
126 void ArgumentCoder<IntSize>::encode(ArgumentEncoder& encoder, const IntSize& intSize)
128 SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
131 bool ArgumentCoder<IntSize>::decode(ArgumentDecoder* decoder, IntSize& intSize)
133 return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
137 void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes)
139 SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
142 bool ArgumentCoder<ViewportAttributes>::decode(ArgumentDecoder* decoder, ViewportAttributes& viewportAttributes)
144 return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
148 void ArgumentCoder<MimeClassInfo>::encode(ArgumentEncoder& encoder, const MimeClassInfo& mimeClassInfo)
150 encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
153 bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder* decoder, MimeClassInfo& mimeClassInfo)
155 if (!decoder->decode(mimeClassInfo.type))
157 if (!decoder->decode(mimeClassInfo.desc))
159 if (!decoder->decode(mimeClassInfo.extensions))
166 void ArgumentCoder<PluginInfo>::encode(ArgumentEncoder& encoder, const PluginInfo& pluginInfo)
168 encoder << pluginInfo.name << pluginInfo.file << pluginInfo.desc << pluginInfo.mimes;
171 bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder* decoder, PluginInfo& pluginInfo)
173 if (!decoder->decode(pluginInfo.name))
175 if (!decoder->decode(pluginInfo.file))
177 if (!decoder->decode(pluginInfo.desc))
179 if (!decoder->decode(pluginInfo.mimes))
186 void ArgumentCoder<HTTPHeaderMap>::encode(ArgumentEncoder& encoder, const HTTPHeaderMap& headerMap)
188 encoder << static_cast<const HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap);
191 bool ArgumentCoder<HTTPHeaderMap>::decode(ArgumentDecoder* decoder, HTTPHeaderMap& headerMap)
193 return decoder->decode(static_cast<HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap));
197 void ArgumentCoder<AuthenticationChallenge>::encode(ArgumentEncoder& encoder, const AuthenticationChallenge& challenge)
199 encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error();
202 bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder* decoder, AuthenticationChallenge& challenge)
204 ProtectionSpace protectionSpace;
205 if (!decoder->decode(protectionSpace))
208 Credential proposedCredential;
209 if (!decoder->decode(proposedCredential))
212 unsigned previousFailureCount;
213 if (!decoder->decode(previousFailureCount))
216 ResourceResponse failureResponse;
217 if (!decoder->decode(failureResponse))
221 if (!decoder->decode(error))
224 challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
229 void ArgumentCoder<ProtectionSpace>::encode(ArgumentEncoder& encoder, const ProtectionSpace& space)
231 encoder << space.host() << space.port() << space.realm();
232 encoder.encodeEnum(space.authenticationScheme());
233 encoder.encodeEnum(space.serverType());
236 bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder* decoder, ProtectionSpace& space)
239 if (!decoder->decode(host))
243 if (!decoder->decode(port))
247 if (!decoder->decode(realm))
250 ProtectionSpaceAuthenticationScheme authenticationScheme;
251 if (!decoder->decodeEnum(authenticationScheme))
254 ProtectionSpaceServerType serverType;
255 if (!decoder->decodeEnum(serverType))
258 space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
262 void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential)
264 encoder << credential.user() << credential.password();
265 encoder.encodeEnum(credential.persistence());
268 bool ArgumentCoder<Credential>::decode(ArgumentDecoder* decoder, Credential& credential)
271 if (!decoder->decode(user))
275 if (!decoder->decode(password))
278 CredentialPersistence persistence;
279 if (!decoder->decodeEnum(persistence))
282 credential = Credential(user, password, persistence);
286 static void encodeImage(ArgumentEncoder& encoder, Image* image)
288 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
289 bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
291 ShareableBitmap::Handle handle;
292 bitmap->createHandle(handle);
297 static bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image)
299 ShareableBitmap::Handle handle;
300 if (!decoder->decode(handle))
303 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
306 image = bitmap->createImage();
312 void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& cursor)
314 encoder.encodeEnum(cursor.type());
316 if (cursor.type() != Cursor::Custom)
319 if (cursor.image()->isNull()) {
320 encoder << false; // There is no valid image being encoded.
325 encodeImage(encoder, cursor.image());
326 encoder << cursor.hotSpot();
329 bool ArgumentCoder<Cursor>::decode(ArgumentDecoder* decoder, Cursor& cursor)
332 if (!decoder->decodeEnum(type))
335 if (type > Cursor::Custom)
338 if (type != Cursor::Custom) {
339 const Cursor& cursorReference = Cursor::fromType(type);
340 // Calling platformCursor here will eagerly create the platform cursor for the cursor singletons inside WebCore.
341 // This will avoid having to re-create the platform cursors over and over.
342 (void)cursorReference.platformCursor();
344 cursor = cursorReference;
348 bool isValidImagePresent;
349 if (!decoder->decode(isValidImagePresent))
352 if (!isValidImagePresent) {
353 cursor = Cursor(Image::nullImage(), IntPoint());
358 if (!decodeImage(decoder, image))
362 if (!decoder->decode(hotSpot))
365 if (!image->rect().contains(hotSpot))
368 cursor = Cursor(image.get(), hotSpot);
372 void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
374 if (kShouldSerializeWebCoreData) {
375 encoder << resourceRequest.url().string();
376 encoder << resourceRequest.httpMethod();
377 encoder << resourceRequest.httpHeaderFields();
379 // FIXME: Do not encode HTTP message body.
380 // 1. It can be large and thus costly to send across.
381 // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
382 FormData* httpBody = resourceRequest.httpBody();
383 encoder << static_cast<bool>(httpBody);
385 encoder << httpBody->flattenToString();
387 encoder << resourceRequest.firstPartyForCookies().string();
390 encodePlatformData(encoder, resourceRequest);
393 bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder* decoder, ResourceRequest& resourceRequest)
395 if (kShouldSerializeWebCoreData) {
396 ResourceRequest request;
399 if (!decoder->decode(url))
401 request.setURL(KURL(KURL(), url));
404 if (!decoder->decode(httpMethod))
406 request.setHTTPMethod(httpMethod);
408 HTTPHeaderMap headers;
409 if (!decoder->decode(headers))
411 request.addHTTPHeaderFields(headers);
414 if (!decoder->decode(hasHTTPBody))
418 if (!decoder->decode(httpBody))
420 request.setHTTPBody(FormData::create(httpBody.utf8()));
423 String firstPartyForCookies;
424 if (!decoder->decode(firstPartyForCookies))
426 request.setFirstPartyForCookies(KURL(KURL(), firstPartyForCookies));
428 resourceRequest = request;
431 return decodePlatformData(decoder, resourceRequest);
434 void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
436 if (kShouldSerializeWebCoreData) {
437 bool responseIsNull = resourceResponse.isNull();
438 encoder << responseIsNull;
442 encoder << resourceResponse.url().string();
443 encoder << static_cast<int32_t>(resourceResponse.httpStatusCode());
444 encoder << resourceResponse.httpHeaderFields();
446 encoder << resourceResponse.mimeType();
447 encoder << resourceResponse.textEncodingName();
448 encoder << static_cast<int64_t>(resourceResponse.expectedContentLength());
449 encoder << resourceResponse.httpStatusText();
450 encoder << resourceResponse.suggestedFilename();
453 encodePlatformData(encoder, resourceResponse);
456 bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder* decoder, ResourceResponse& resourceResponse)
458 if (kShouldSerializeWebCoreData) {
460 if (!decoder->decode(responseIsNull))
462 if (responseIsNull) {
463 resourceResponse = ResourceResponse();
467 ResourceResponse response;
470 if (!decoder->decode(url))
472 response.setURL(KURL(KURL(), url));
474 int32_t httpStatusCode;
475 if (!decoder->decode(httpStatusCode))
477 response.setHTTPStatusCode(httpStatusCode);
479 HTTPHeaderMap headers;
480 if (!decoder->decode(headers))
482 for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it)
483 response.setHTTPHeaderField(it->key, it->value);
486 if (!decoder->decode(mimeType))
488 response.setMimeType(mimeType);
490 String textEncodingName;
491 if (!decoder->decode(textEncodingName))
493 response.setTextEncodingName(textEncodingName);
495 int64_t contentLength;
496 if (!decoder->decode(contentLength))
498 response.setExpectedContentLength(contentLength);
500 String httpStatusText;
501 if (!decoder->decode(httpStatusText))
503 response.setHTTPStatusText(httpStatusText);
505 String suggestedFilename;
506 if (!decoder->decode(suggestedFilename))
508 response.setSuggestedFilename(suggestedFilename);
510 resourceResponse = response;
513 return decodePlatformData(decoder, resourceResponse);
516 void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError)
518 if (kShouldSerializeWebCoreData) {
519 bool errorIsNull = resourceError.isNull();
520 encoder << errorIsNull;
524 encoder << resourceError.domain();
525 encoder << resourceError.errorCode();
526 encoder << resourceError.failingURL();
527 encoder << resourceError.localizedDescription();
528 encoder << resourceError.isCancellation();
529 encoder << resourceError.isTimeout();
532 encodePlatformData(encoder, resourceError);
535 bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder* decoder, ResourceError& resourceError)
537 if (kShouldSerializeWebCoreData) {
539 if (!decoder->decode(errorIsNull))
542 resourceError = ResourceError();
547 if (!decoder->decode(domain))
551 if (!decoder->decode(errorCode))
555 if (!decoder->decode(failingURL))
558 String localizedDescription;
559 if (!decoder->decode(localizedDescription))
563 if (!decoder->decode(isCancellation))
567 if (!decoder->decode(isTimeout))
570 resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
571 resourceError.setIsCancellation(isCancellation);
572 resourceError.setIsTimeout(isTimeout);
575 return decodePlatformData(decoder, resourceError);
578 void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures)
580 encoder << windowFeatures.x;
581 encoder << windowFeatures.y;
582 encoder << windowFeatures.width;
583 encoder << windowFeatures.height;
584 encoder << windowFeatures.xSet;
585 encoder << windowFeatures.ySet;
586 encoder << windowFeatures.widthSet;
587 encoder << windowFeatures.heightSet;
588 encoder << windowFeatures.menuBarVisible;
589 encoder << windowFeatures.statusBarVisible;
590 encoder << windowFeatures.toolBarVisible;
591 encoder << windowFeatures.locationBarVisible;
592 encoder << windowFeatures.scrollbarsVisible;
593 encoder << windowFeatures.resizable;
594 encoder << windowFeatures.fullscreen;
595 encoder << windowFeatures.dialog;
598 bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder* decoder, WindowFeatures& windowFeatures)
600 if (!decoder->decode(windowFeatures.x))
602 if (!decoder->decode(windowFeatures.y))
604 if (!decoder->decode(windowFeatures.width))
606 if (!decoder->decode(windowFeatures.height))
608 if (!decoder->decode(windowFeatures.xSet))
610 if (!decoder->decode(windowFeatures.ySet))
612 if (!decoder->decode(windowFeatures.widthSet))
614 if (!decoder->decode(windowFeatures.heightSet))
616 if (!decoder->decode(windowFeatures.menuBarVisible))
618 if (!decoder->decode(windowFeatures.statusBarVisible))
620 if (!decoder->decode(windowFeatures.toolBarVisible))
622 if (!decoder->decode(windowFeatures.locationBarVisible))
624 if (!decoder->decode(windowFeatures.scrollbarsVisible))
626 if (!decoder->decode(windowFeatures.resizable))
628 if (!decoder->decode(windowFeatures.fullscreen))
630 if (!decoder->decode(windowFeatures.dialog))
636 void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color)
638 if (!color.isValid()) {
644 encoder << color.rgb();
647 bool ArgumentCoder<Color>::decode(ArgumentDecoder* decoder, Color& color)
650 if (!decoder->decode(isValid))
659 if (!decoder->decode(rgba))
667 void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline)
669 encoder << underline.startOffset;
670 encoder << underline.endOffset;
671 encoder << underline.thick;
672 encoder << underline.color;
675 bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder* decoder, CompositionUnderline& underline)
677 if (!decoder->decode(underline.startOffset))
679 if (!decoder->decode(underline.endOffset))
681 if (!decoder->decode(underline.thick))
683 if (!decoder->decode(underline.color))
690 void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cookie)
692 encoder << cookie.name;
693 encoder << cookie.value;
694 encoder << cookie.domain;
695 encoder << cookie.path;
696 encoder << cookie.expires;
697 encoder << cookie.httpOnly;
698 encoder << cookie.secure;
699 encoder << cookie.session;
702 bool ArgumentCoder<Cookie>::decode(ArgumentDecoder* decoder, Cookie& cookie)
704 if (!decoder->decode(cookie.name))
706 if (!decoder->decode(cookie.value))
708 if (!decoder->decode(cookie.domain))
710 if (!decoder->decode(cookie.path))
712 if (!decoder->decode(cookie.expires))
714 if (!decoder->decode(cookie.httpOnly))
716 if (!decoder->decode(cookie.secure))
718 if (!decoder->decode(cookie.session))
725 #if ENABLE(SQL_DATABASE)
726 void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const DatabaseDetails& details)
728 encoder << details.name();
729 encoder << details.displayName();
730 encoder << details.expectedUsage();
731 encoder << details.currentUsage();
734 bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder* decoder, DatabaseDetails& details)
737 if (!decoder->decode(name))
741 if (!decoder->decode(displayName))
744 uint64_t expectedUsage;
745 if (!decoder->decode(expectedUsage))
748 uint64_t currentUsage;
749 if (!decoder->decode(currentUsage))
752 details = DatabaseDetails(name, displayName, expectedUsage, currentUsage);
757 void ArgumentCoder<DictationAlternative>::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative)
759 encoder << dictationAlternative.rangeStart;
760 encoder << dictationAlternative.rangeLength;
761 encoder << dictationAlternative.dictationContext;
764 bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder* decoder, DictationAlternative& dictationAlternative)
766 if (!decoder->decode(dictationAlternative.rangeStart))
768 if (!decoder->decode(dictationAlternative.rangeLength))
770 if (!decoder->decode(dictationAlternative.dictationContext))
776 void ArgumentCoder<FileChooserSettings>::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings)
778 encoder << settings.allowsMultipleFiles;
779 #if ENABLE(DIRECTORY_UPLOAD)
780 encoder << settings.allowsDirectoryUpload;
782 encoder << settings.acceptMIMETypes;
783 encoder << settings.selectedFiles;
784 #if ENABLE(MEDIA_CAPTURE)
785 encoder << settings.capture;
789 bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder* decoder, FileChooserSettings& settings)
791 if (!decoder->decode(settings.allowsMultipleFiles))
793 #if ENABLE(DIRECTORY_UPLOAD)
794 if (!decoder->decode(settings.allowsDirectoryUpload))
797 if (!decoder->decode(settings.acceptMIMETypes))
799 if (!decoder->decode(settings.selectedFiles))
801 #if ENABLE(MEDIA_CAPTURE)
802 if (!decoder->decode(settings.capture))
810 void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const GrammarDetail& detail)
812 encoder << detail.location;
813 encoder << detail.length;
814 encoder << detail.guesses;
815 encoder << detail.userDescription;
818 bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder* decoder, GrammarDetail& detail)
820 if (!decoder->decode(detail.location))
822 if (!decoder->decode(detail.length))
824 if (!decoder->decode(detail.guesses))
826 if (!decoder->decode(detail.userDescription))
833 void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const TextCheckingResult& result)
835 encoder.encodeEnum(result.type);
836 encoder << result.location;
837 encoder << result.length;
838 encoder << result.details;
839 encoder << result.replacement;
842 bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder* decoder, TextCheckingResult& result)
844 if (!decoder->decodeEnum(result.type))
846 if (!decoder->decode(result.location))
848 if (!decoder->decode(result.length))
850 if (!decoder->decode(result.details))
852 if (!decoder->decode(result.replacement))
857 void ArgumentCoder<DragSession>::encode(ArgumentEncoder& encoder, const DragSession& result)
859 encoder.encodeEnum(result.operation);
860 encoder << result.mouseIsOverFileInput;
861 encoder << result.numberOfItemsToBeAccepted;
864 bool ArgumentCoder<DragSession>::decode(ArgumentDecoder* decoder, DragSession& result)
866 if (!decoder->decodeEnum(result.operation))
868 if (!decoder->decode(result.mouseIsOverFileInput))
870 if (!decoder->decode(result.numberOfItemsToBeAccepted))
875 void ArgumentCoder<KURL>::encode(ArgumentEncoder& encoder, const KURL& result)
877 encoder << result.string();
880 bool ArgumentCoder<KURL>::decode(ArgumentDecoder* decoder, KURL& result)
883 if (!decoder->decode(urlAsString))
885 result = KURL(WebCore::ParsedURLString, urlAsString);
889 void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, const WebCore::UserStyleSheet& userStyleSheet)
891 encoder << userStyleSheet.source();
892 encoder << userStyleSheet.url();
893 encoder << userStyleSheet.whitelist();
894 encoder << userStyleSheet.blacklist();
895 encoder.encodeEnum(userStyleSheet.injectedFrames());
896 encoder.encodeEnum(userStyleSheet.level());
899 bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder* decoder, WebCore::UserStyleSheet& userStyleSheet)
902 if (!decoder->decode(source))
906 if (!decoder->decode(url))
909 Vector<String> whitelist;
910 if (!decoder->decode(whitelist))
913 Vector<String> blacklist;
914 if (!decoder->decode(blacklist))
917 WebCore::UserContentInjectedFrames injectedFrames;
918 if (!decoder->decodeEnum(injectedFrames))
921 WebCore::UserStyleLevel level;
922 if (!decoder->decodeEnum(level))
925 userStyleSheet = WebCore::UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level);
929 void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const WebCore::UserScript& userScript)
931 encoder << userScript.source();
932 encoder << userScript.url();
933 encoder << userScript.whitelist();
934 encoder << userScript.blacklist();
935 encoder.encodeEnum(userScript.injectionTime());
936 encoder.encodeEnum(userScript.injectedFrames());
939 bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder* decoder, WebCore::UserScript& userScript)
942 if (!decoder->decode(source))
946 if (!decoder->decode(url))
949 Vector<String> whitelist;
950 if (!decoder->decode(whitelist))
953 Vector<String> blacklist;
954 if (!decoder->decode(blacklist))
957 WebCore::UserScriptInjectionTime injectionTime;
958 if (!decoder->decodeEnum(injectionTime))
961 WebCore::UserContentInjectedFrames injectedFrames;
962 if (!decoder->decodeEnum(injectedFrames))
965 userScript = WebCore::UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames);
969 } // namespace CoreIPC