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() << challenge.identifier();
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))
225 if (!decoder->decode(identifier))
228 challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error, identifier);
233 void ArgumentCoder<ProtectionSpace>::encode(ArgumentEncoder& encoder, const ProtectionSpace& space)
235 encoder << space.host() << space.port() << space.realm();
236 encoder.encodeEnum(space.authenticationScheme());
237 encoder.encodeEnum(space.serverType());
240 bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder* decoder, ProtectionSpace& space)
243 if (!decoder->decode(host))
247 if (!decoder->decode(port))
251 if (!decoder->decode(realm))
254 ProtectionSpaceAuthenticationScheme authenticationScheme;
255 if (!decoder->decodeEnum(authenticationScheme))
258 ProtectionSpaceServerType serverType;
259 if (!decoder->decodeEnum(serverType))
262 space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
266 void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential)
268 encoder << credential.user() << credential.password();
269 encoder.encodeEnum(credential.persistence());
272 bool ArgumentCoder<Credential>::decode(ArgumentDecoder* decoder, Credential& credential)
275 if (!decoder->decode(user))
279 if (!decoder->decode(password))
282 CredentialPersistence persistence;
283 if (!decoder->decodeEnum(persistence))
286 credential = Credential(user, password, persistence);
290 static void encodeImage(ArgumentEncoder& encoder, Image* image)
292 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
293 bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
295 ShareableBitmap::Handle handle;
296 bitmap->createHandle(handle);
301 static bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image)
303 ShareableBitmap::Handle handle;
304 if (!decoder->decode(handle))
307 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
310 image = bitmap->createImage();
316 void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& cursor)
318 encoder.encodeEnum(cursor.type());
320 if (cursor.type() != Cursor::Custom)
323 if (cursor.image()->isNull()) {
324 encoder << false; // There is no valid image being encoded.
329 encodeImage(encoder, cursor.image());
330 encoder << cursor.hotSpot();
333 bool ArgumentCoder<Cursor>::decode(ArgumentDecoder* decoder, Cursor& cursor)
336 if (!decoder->decodeEnum(type))
339 if (type > Cursor::Custom)
342 if (type != Cursor::Custom) {
343 const Cursor& cursorReference = Cursor::fromType(type);
344 // Calling platformCursor here will eagerly create the platform cursor for the cursor singletons inside WebCore.
345 // This will avoid having to re-create the platform cursors over and over.
346 (void)cursorReference.platformCursor();
348 cursor = cursorReference;
352 bool isValidImagePresent;
353 if (!decoder->decode(isValidImagePresent))
356 if (!isValidImagePresent) {
357 cursor = Cursor(Image::nullImage(), IntPoint());
362 if (!decodeImage(decoder, image))
366 if (!decoder->decode(hotSpot))
369 if (!image->rect().contains(hotSpot))
372 cursor = Cursor(image.get(), hotSpot);
376 void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
378 if (kShouldSerializeWebCoreData) {
379 encoder << resourceRequest.url().string();
380 encoder << resourceRequest.httpMethod();
381 encoder << resourceRequest.httpHeaderFields();
383 // FIXME: Do not encode HTTP message body.
384 // 1. It can be large and thus costly to send across.
385 // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
386 FormData* httpBody = resourceRequest.httpBody();
387 encoder << static_cast<bool>(httpBody);
389 encoder << httpBody->flattenToString();
391 encoder << resourceRequest.firstPartyForCookies().string();
394 encodePlatformData(encoder, resourceRequest);
397 bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder* decoder, ResourceRequest& resourceRequest)
399 if (kShouldSerializeWebCoreData) {
400 ResourceRequest request;
403 if (!decoder->decode(url))
405 request.setURL(KURL(KURL(), url));
408 if (!decoder->decode(httpMethod))
410 request.setHTTPMethod(httpMethod);
412 HTTPHeaderMap headers;
413 if (!decoder->decode(headers))
415 request.addHTTPHeaderFields(headers);
418 if (!decoder->decode(hasHTTPBody))
422 if (!decoder->decode(httpBody))
424 request.setHTTPBody(FormData::create(httpBody.utf8()));
427 String firstPartyForCookies;
428 if (!decoder->decode(firstPartyForCookies))
430 request.setFirstPartyForCookies(KURL(KURL(), firstPartyForCookies));
432 resourceRequest = request;
435 return decodePlatformData(decoder, resourceRequest);
438 void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
440 if (kShouldSerializeWebCoreData) {
441 bool responseIsNull = resourceResponse.isNull();
442 encoder << responseIsNull;
446 encoder << resourceResponse.url().string();
447 encoder << static_cast<int32_t>(resourceResponse.httpStatusCode());
448 encoder << resourceResponse.httpHeaderFields();
450 encoder << resourceResponse.mimeType();
451 encoder << resourceResponse.textEncodingName();
452 encoder << static_cast<int64_t>(resourceResponse.expectedContentLength());
453 encoder << resourceResponse.httpStatusText();
454 encoder << resourceResponse.suggestedFilename();
457 encodePlatformData(encoder, resourceResponse);
460 bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder* decoder, ResourceResponse& resourceResponse)
462 if (kShouldSerializeWebCoreData) {
464 if (!decoder->decode(responseIsNull))
466 if (responseIsNull) {
467 resourceResponse = ResourceResponse();
471 ResourceResponse response;
474 if (!decoder->decode(url))
476 response.setURL(KURL(KURL(), url));
478 int32_t httpStatusCode;
479 if (!decoder->decode(httpStatusCode))
481 response.setHTTPStatusCode(httpStatusCode);
483 HTTPHeaderMap headers;
484 if (!decoder->decode(headers))
486 for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it)
487 response.setHTTPHeaderField(it->key, it->value);
490 if (!decoder->decode(mimeType))
492 response.setMimeType(mimeType);
494 String textEncodingName;
495 if (!decoder->decode(textEncodingName))
497 response.setTextEncodingName(textEncodingName);
499 int64_t contentLength;
500 if (!decoder->decode(contentLength))
502 response.setExpectedContentLength(contentLength);
504 String httpStatusText;
505 if (!decoder->decode(httpStatusText))
507 response.setHTTPStatusText(httpStatusText);
509 String suggestedFilename;
510 if (!decoder->decode(suggestedFilename))
512 response.setSuggestedFilename(suggestedFilename);
514 resourceResponse = response;
517 return decodePlatformData(decoder, resourceResponse);
520 void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError)
522 if (kShouldSerializeWebCoreData) {
523 bool errorIsNull = resourceError.isNull();
524 encoder << errorIsNull;
528 encoder << resourceError.domain();
529 encoder << resourceError.errorCode();
530 encoder << resourceError.failingURL();
531 encoder << resourceError.localizedDescription();
532 encoder << resourceError.isCancellation();
533 encoder << resourceError.isTimeout();
536 encodePlatformData(encoder, resourceError);
539 bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder* decoder, ResourceError& resourceError)
541 if (kShouldSerializeWebCoreData) {
543 if (!decoder->decode(errorIsNull))
546 resourceError = ResourceError();
551 if (!decoder->decode(domain))
555 if (!decoder->decode(errorCode))
559 if (!decoder->decode(failingURL))
562 String localizedDescription;
563 if (!decoder->decode(localizedDescription))
567 if (!decoder->decode(isCancellation))
571 if (!decoder->decode(isTimeout))
574 resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
575 resourceError.setIsCancellation(isCancellation);
576 resourceError.setIsTimeout(isTimeout);
579 return decodePlatformData(decoder, resourceError);
582 void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures)
584 encoder << windowFeatures.x;
585 encoder << windowFeatures.y;
586 encoder << windowFeatures.width;
587 encoder << windowFeatures.height;
588 encoder << windowFeatures.xSet;
589 encoder << windowFeatures.ySet;
590 encoder << windowFeatures.widthSet;
591 encoder << windowFeatures.heightSet;
592 encoder << windowFeatures.menuBarVisible;
593 encoder << windowFeatures.statusBarVisible;
594 encoder << windowFeatures.toolBarVisible;
595 encoder << windowFeatures.locationBarVisible;
596 encoder << windowFeatures.scrollbarsVisible;
597 encoder << windowFeatures.resizable;
598 encoder << windowFeatures.fullscreen;
599 encoder << windowFeatures.dialog;
602 bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder* decoder, WindowFeatures& windowFeatures)
604 if (!decoder->decode(windowFeatures.x))
606 if (!decoder->decode(windowFeatures.y))
608 if (!decoder->decode(windowFeatures.width))
610 if (!decoder->decode(windowFeatures.height))
612 if (!decoder->decode(windowFeatures.xSet))
614 if (!decoder->decode(windowFeatures.ySet))
616 if (!decoder->decode(windowFeatures.widthSet))
618 if (!decoder->decode(windowFeatures.heightSet))
620 if (!decoder->decode(windowFeatures.menuBarVisible))
622 if (!decoder->decode(windowFeatures.statusBarVisible))
624 if (!decoder->decode(windowFeatures.toolBarVisible))
626 if (!decoder->decode(windowFeatures.locationBarVisible))
628 if (!decoder->decode(windowFeatures.scrollbarsVisible))
630 if (!decoder->decode(windowFeatures.resizable))
632 if (!decoder->decode(windowFeatures.fullscreen))
634 if (!decoder->decode(windowFeatures.dialog))
640 void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color)
642 if (!color.isValid()) {
648 encoder << color.rgb();
651 bool ArgumentCoder<Color>::decode(ArgumentDecoder* decoder, Color& color)
654 if (!decoder->decode(isValid))
663 if (!decoder->decode(rgba))
671 void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline)
673 encoder << underline.startOffset;
674 encoder << underline.endOffset;
675 encoder << underline.thick;
676 encoder << underline.color;
679 bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder* decoder, CompositionUnderline& underline)
681 if (!decoder->decode(underline.startOffset))
683 if (!decoder->decode(underline.endOffset))
685 if (!decoder->decode(underline.thick))
687 if (!decoder->decode(underline.color))
694 void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cookie)
696 encoder << cookie.name;
697 encoder << cookie.value;
698 encoder << cookie.domain;
699 encoder << cookie.path;
700 encoder << cookie.expires;
701 encoder << cookie.httpOnly;
702 encoder << cookie.secure;
703 encoder << cookie.session;
706 bool ArgumentCoder<Cookie>::decode(ArgumentDecoder* decoder, Cookie& cookie)
708 if (!decoder->decode(cookie.name))
710 if (!decoder->decode(cookie.value))
712 if (!decoder->decode(cookie.domain))
714 if (!decoder->decode(cookie.path))
716 if (!decoder->decode(cookie.expires))
718 if (!decoder->decode(cookie.httpOnly))
720 if (!decoder->decode(cookie.secure))
722 if (!decoder->decode(cookie.session))
729 #if ENABLE(SQL_DATABASE)
730 void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const DatabaseDetails& details)
732 encoder << details.name();
733 encoder << details.displayName();
734 encoder << details.expectedUsage();
735 encoder << details.currentUsage();
738 bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder* decoder, DatabaseDetails& details)
741 if (!decoder->decode(name))
745 if (!decoder->decode(displayName))
748 uint64_t expectedUsage;
749 if (!decoder->decode(expectedUsage))
752 uint64_t currentUsage;
753 if (!decoder->decode(currentUsage))
756 details = DatabaseDetails(name, displayName, expectedUsage, currentUsage);
761 void ArgumentCoder<DictationAlternative>::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative)
763 encoder << dictationAlternative.rangeStart;
764 encoder << dictationAlternative.rangeLength;
765 encoder << dictationAlternative.dictationContext;
768 bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder* decoder, DictationAlternative& dictationAlternative)
770 if (!decoder->decode(dictationAlternative.rangeStart))
772 if (!decoder->decode(dictationAlternative.rangeLength))
774 if (!decoder->decode(dictationAlternative.dictationContext))
780 void ArgumentCoder<FileChooserSettings>::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings)
782 encoder << settings.allowsMultipleFiles;
783 #if ENABLE(DIRECTORY_UPLOAD)
784 encoder << settings.allowsDirectoryUpload;
786 encoder << settings.acceptMIMETypes;
787 encoder << settings.selectedFiles;
788 #if ENABLE(MEDIA_CAPTURE)
789 encoder << settings.capture;
793 bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder* decoder, FileChooserSettings& settings)
795 if (!decoder->decode(settings.allowsMultipleFiles))
797 #if ENABLE(DIRECTORY_UPLOAD)
798 if (!decoder->decode(settings.allowsDirectoryUpload))
801 if (!decoder->decode(settings.acceptMIMETypes))
803 if (!decoder->decode(settings.selectedFiles))
805 #if ENABLE(MEDIA_CAPTURE)
806 if (!decoder->decode(settings.capture))
814 void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const GrammarDetail& detail)
816 encoder << detail.location;
817 encoder << detail.length;
818 encoder << detail.guesses;
819 encoder << detail.userDescription;
822 bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder* decoder, GrammarDetail& detail)
824 if (!decoder->decode(detail.location))
826 if (!decoder->decode(detail.length))
828 if (!decoder->decode(detail.guesses))
830 if (!decoder->decode(detail.userDescription))
837 void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const TextCheckingResult& result)
839 encoder.encodeEnum(result.type);
840 encoder << result.location;
841 encoder << result.length;
842 encoder << result.details;
843 encoder << result.replacement;
846 bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder* decoder, TextCheckingResult& result)
848 if (!decoder->decodeEnum(result.type))
850 if (!decoder->decode(result.location))
852 if (!decoder->decode(result.length))
854 if (!decoder->decode(result.details))
856 if (!decoder->decode(result.replacement))
861 void ArgumentCoder<DragSession>::encode(ArgumentEncoder& encoder, const DragSession& result)
863 encoder.encodeEnum(result.operation);
864 encoder << result.mouseIsOverFileInput;
865 encoder << result.numberOfItemsToBeAccepted;
868 bool ArgumentCoder<DragSession>::decode(ArgumentDecoder* decoder, DragSession& result)
870 if (!decoder->decodeEnum(result.operation))
872 if (!decoder->decode(result.mouseIsOverFileInput))
874 if (!decoder->decode(result.numberOfItemsToBeAccepted))
879 void ArgumentCoder<KURL>::encode(ArgumentEncoder& encoder, const KURL& result)
881 encoder << result.string();
884 bool ArgumentCoder<KURL>::decode(ArgumentDecoder* decoder, KURL& result)
887 if (!decoder->decode(urlAsString))
889 result = KURL(WebCore::ParsedURLString, urlAsString);
893 void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, const WebCore::UserStyleSheet& userStyleSheet)
895 encoder << userStyleSheet.source();
896 encoder << userStyleSheet.url();
897 encoder << userStyleSheet.whitelist();
898 encoder << userStyleSheet.blacklist();
899 encoder.encodeEnum(userStyleSheet.injectedFrames());
900 encoder.encodeEnum(userStyleSheet.level());
903 bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder* decoder, WebCore::UserStyleSheet& userStyleSheet)
906 if (!decoder->decode(source))
910 if (!decoder->decode(url))
913 Vector<String> whitelist;
914 if (!decoder->decode(whitelist))
917 Vector<String> blacklist;
918 if (!decoder->decode(blacklist))
921 WebCore::UserContentInjectedFrames injectedFrames;
922 if (!decoder->decodeEnum(injectedFrames))
925 WebCore::UserStyleLevel level;
926 if (!decoder->decodeEnum(level))
929 userStyleSheet = WebCore::UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level);
933 void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const WebCore::UserScript& userScript)
935 encoder << userScript.source();
936 encoder << userScript.url();
937 encoder << userScript.whitelist();
938 encoder << userScript.blacklist();
939 encoder.encodeEnum(userScript.injectionTime());
940 encoder.encodeEnum(userScript.injectedFrames());
943 bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder* decoder, WebCore::UserScript& userScript)
946 if (!decoder->decode(source))
950 if (!decoder->decode(url))
953 Vector<String> whitelist;
954 if (!decoder->decode(whitelist))
957 Vector<String> blacklist;
958 if (!decoder->decode(blacklist))
961 WebCore::UserScriptInjectionTime injectionTime;
962 if (!decoder->decodeEnum(injectionTime))
965 WebCore::UserContentInjectedFrames injectedFrames;
966 if (!decoder->decodeEnum(injectedFrames))
969 userScript = WebCore::UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames);
973 } // namespace CoreIPC