Changeset 215322 in webkit
- Timestamp:
- Apr 13, 2017 9:40:25 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r215321 r215322 1 2017-04-13 Romain Bellessort <romain.bellessort@crf.canon.fr> 2 3 [Readable Streams API] Implement cloneArrayBuffer in WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=170008 5 6 Reviewed by Youenn Fablet. 7 8 Added test to check cloneArrayBuffer behaviour. 9 10 * streams/clone-array-buffer-expected.txt: Added. 11 * streams/clone-array-buffer.html: Added. 12 1 13 2017-04-13 Youenn Fablet <youenn@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r215321 r215322 1 2017-04-13 Romain Bellessort <romain.bellessort@crf.canon.fr> 2 3 [Readable Streams API] Implement cloneArrayBuffer in WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=170008 5 6 Reviewed by Youenn Fablet. 7 8 Implemented cloneArrayBuffer based on existing structuredCloneArrayBuffer 9 implementation. The code has been factorized so that both cloneArrayBuffer 10 and structuredCloneArrayBuffer rely on the same code (which is basically 11 the previous implementation of structuredCloneArrayBuffer + the ability 12 to clone only a part of considered buffer). 13 14 Test: streams/clone-array-buffer.html 15 16 * Modules/streams/ReadableByteStreamInternals.js: Deleted cloneArrayBuffer JS implementation. 17 * bindings/js/JSDOMGlobalObject.cpp: 18 (WebCore::JSDOMGlobalObject::addBuiltinGlobals): Add cloneArrayBuffer private declaration. 19 * bindings/js/StructuredClone.cpp: 20 (WebCore::cloneArrayBufferImpl): Added (mostly based on previous structuredCloneArrayBuffer). 21 (WebCore::cloneArrayBuffer): Added. 22 (WebCore::structuredCloneArrayBuffer): Updated. 23 * bindings/js/StructuredClone.h: Added cloneArrayBuffer declaration. 24 * bindings/js/WebCoreBuiltinNames.h: Added cloneArrayBuffer declaration. 25 * testing/Internals.cpp: Added support for testing cloneArrayBuffer. 26 * testing/Internals.h: Added support for testing cloneArrayBuffer. 27 * testing/Internals.idl: Added support for testing cloneArrayBuffer. 28 1 29 2017-04-13 Youenn Fablet <youenn@apple.com> 2 30 -
trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js
r215043 r215322 397 397 } 398 398 399 function cloneArrayBuffer(srcBuffer, srcByteOffset, srcLength)400 {401 "use strict";402 403 // FIXME: Below implementation returns the appropriate data but does not perform404 // exactly what is described by ECMAScript CloneArrayBuffer operation. This should405 // be fixed in a follow up patch implementing cloneArrayBuffer in JSC (similarly to406 // structuredCloneArrayBuffer implementation).407 return srcBuffer.slice(srcByteOffset, srcByteOffset + srcLength);408 }409 410 399 function readableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) 411 400 { -
trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp
r214713 r215322 143 143 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeGetterTypeErrorPrivateName(), 144 144 JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), DontDelete | ReadOnly), 145 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().cloneArrayBufferPrivateName(), 146 JSFunction::create(vm, this, 3, String(), cloneArrayBuffer), DontDelete | ReadOnly), 145 147 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferPrivateName(), 146 148 JSFunction::create(vm, this, 1, String(), structuredCloneArrayBuffer), DontDelete | ReadOnly), -
trunk/Source/WebCore/bindings/js/StructuredClone.cpp
r214713 r215322 36 36 namespace WebCore { 37 37 38 EncodedJSValue JSC_HOST_CALL structuredCloneArrayBuffer(ExecState* state) 38 enum class CloneMode { 39 Full, 40 Partial, 41 }; 42 43 EncodedJSValue JSC_HOST_CALL cloneArrayBufferImpl(ExecState*, CloneMode); 44 45 EncodedJSValue JSC_HOST_CALL cloneArrayBufferImpl(ExecState* state, CloneMode mode) 39 46 { 40 47 ASSERT(state); … … 49 56 return { }; 50 57 } 58 if (mode == CloneMode::Partial) { 59 ASSERT(state->argumentCount() == 3); 60 int srcByteOffset = static_cast<int>(state->uncheckedArgument(1).toNumber(state)); 61 int srcLength = static_cast<int>(state->uncheckedArgument(2).toNumber(state)); 62 return JSValue::encode(JSArrayBuffer::create(state->vm(), state->lexicalGlobalObject()->arrayBufferStructure(ArrayBufferSharingMode::Default), buffer->slice(srcByteOffset, srcByteOffset + srcLength))); 63 } 51 64 return JSValue::encode(JSArrayBuffer::create(state->vm(), state->lexicalGlobalObject()->arrayBufferStructure(ArrayBufferSharingMode::Default), ArrayBuffer::tryCreate(buffer->data(), buffer->byteLength()))); 65 } 66 67 EncodedJSValue JSC_HOST_CALL cloneArrayBuffer(ExecState* state) 68 { 69 return cloneArrayBufferImpl(state, CloneMode::Partial); 70 } 71 72 EncodedJSValue JSC_HOST_CALL structuredCloneArrayBuffer(ExecState* state) 73 { 74 return cloneArrayBufferImpl(state, CloneMode::Full); 52 75 } 53 76 -
trunk/Source/WebCore/bindings/js/StructuredClone.h
r214713 r215322 32 32 namespace WebCore { 33 33 34 JSC::EncodedJSValue JSC_HOST_CALL cloneArrayBuffer(JSC::ExecState*); 34 35 JSC::EncodedJSValue JSC_HOST_CALL structuredCloneArrayBuffer(JSC::ExecState*); 35 36 JSC::EncodedJSValue JSC_HOST_CALL structuredCloneArrayBufferView(JSC::ExecState*); -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r214713 r215322 40 40 macro(byobRequest) \ 41 41 macro(cancel) \ 42 macro(cloneArrayBuffer) \ 42 43 macro(cloneForJS) \ 43 44 macro(closeRequested) \ -
trunk/Source/WebCore/testing/Internals.cpp
r215263 r215322 355 355 else 356 356 return false; 357 357 358 358 return true; 359 359 } … … 395 395 396 396 page.setDefersLoading(false); 397 397 398 398 page.mainFrame().setTextZoomFactor(1.0f); 399 399 400 400 FrameView* mainFrameView = page.mainFrame().view(); 401 401 if (mainFrameView) { … … 599 599 ResourceRequest request(contextDocument()->completeURL(url)); 600 600 request.setDomainForCachePartition(contextDocument()->topOrigin().domainForCachePartition()); 601 601 602 602 CachedResource* resource = MemoryCache::singleton().resourceForRequest(request, contextDocument()->page()->sessionID()); 603 603 return resource && resource->status() == CachedResource::Cached; … … 756 756 if (!cachedImage) 757 757 return; 758 758 759 759 auto* image = cachedImage->image(); 760 760 if (!is<BitmapImage>(image)) 761 761 return; 762 762 763 763 downcast<BitmapImage>(*image).setFrameDecodingDurationForTesting(Seconds { duration }); 764 764 } … … 1031 1031 continue; 1032 1032 } 1033 1033 1034 1034 StyleRuleGroup* groupRule = nullptr; 1035 1035 if (is<StyleRuleMedia>(rule.get())) … … 1039 1039 if (!groupRule) 1040 1040 continue; 1041 1041 1042 1042 auto* groupChildRules = groupRule->childRulesWithoutDeferredParsing(); 1043 1043 if (!groupChildRules) 1044 1044 continue; 1045 1045 1046 1046 count += deferredStyleRulesCountForList(*groupChildRules); 1047 1047 } … … 1066 1066 if (!groupRule) 1067 1067 continue; 1068 1068 1069 1069 auto* groupChildRules = groupRule->childRulesWithoutDeferredParsing(); 1070 1070 if (!groupChildRules) … … 1091 1091 continue; 1092 1092 } 1093 1093 1094 1094 StyleRuleGroup* groupRule = nullptr; 1095 1095 if (is<StyleRuleMedia>(rule.get())) … … 1099 1099 if (!groupRule) 1100 1100 continue; 1101 1101 1102 1102 auto* groupChildRules = groupRule->childRulesWithoutDeferredParsing(); 1103 1103 if (!groupChildRules) 1104 1104 continue; 1105 1105 1106 1106 count += deferredKeyframesRulesCountForList(*groupChildRules); 1107 1107 } 1108 1108 1109 1109 return count; 1110 1110 } … … 1179 1179 if (!behavior) 1180 1180 return std::nullopt; 1181 1181 1182 1182 switch (behavior.value()) { 1183 1183 case WebCore::EventThrottlingBehavior::Responsive: … … 1244 1244 if (!synthesis) 1245 1245 return; 1246 1246 1247 1247 synthesis->setPlatformSynthesizer(std::make_unique<PlatformSpeechSynthesizerMock>(synthesis)); 1248 1248 } … … 1693 1693 1694 1694 document->updateLayoutIgnorePendingStylesheets(); 1695 1695 1696 1696 HitTestResult result = document->frame()->mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y)); 1697 1697 NSDictionary *options = nullptr; … … 1849 1849 HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding); 1850 1850 renderView->hitTest(request, result); 1851 1851 1852 1852 const HitTestResult::NodeSet& nodeSet = result.rectBasedTestResult(); 1853 1853 matches.reserveInitialCapacity(nodeSet.size()); … … 1970 1970 return document->frame()->editor().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); 1971 1971 } 1972 1972 1973 1973 bool Internals::hasAutocorrectedMarker(int from, int length) 1974 1974 { … … 2223 2223 return count; 2224 2224 } 2225 2225 2226 2226 ExceptionOr<bool> Internals::isPageBoxVisible(int pageNumber) 2227 2227 { … … 2276 2276 if (!layerModelObject.layer()->isComposited()) 2277 2277 return Exception { NOT_FOUND_ERR }; 2278 2278 2279 2279 auto* backing = layerModelObject.layer()->backing(); 2280 2280 return backing->graphicsLayer()->primaryLayerID(); … … 2345 2345 if (!element.renderer()->hasLayer()) 2346 2346 return Exception { INVALID_ACCESS_ERR }; 2347 2347 2348 2348 RenderLayer* layer = downcast<RenderLayerModelObject>(element.renderer())->layer(); 2349 2349 if (!layer->isComposited()) 2350 2350 return Exception { INVALID_ACCESS_ERR }; 2351 2351 2352 2352 layer->backing()->setUsesDisplayListDrawing(usesDisplayListDrawing); 2353 2353 return { }; … … 2374 2374 if (!layer->isComposited()) 2375 2375 return Exception { INVALID_ACCESS_ERR }; 2376 2376 2377 2377 layer->backing()->setIsTrackingDisplayListReplay(isTrackingReplay); 2378 2378 return { }; … … 2614 2614 document->view()->setFooterHeight(height); 2615 2615 } 2616 2616 2617 2617 void Internals::setTopContentInset(float contentInset) 2618 2618 { … … 2758 2758 if (!document) 2759 2759 return Exception { INVALID_ACCESS_ERR }; 2760 2760 2761 2761 return document->styleRecalcCount(); 2762 2762 } … … 2785 2785 if (!document || !document->renderView()) 2786 2786 return Exception { INVALID_ACCESS_ERR }; 2787 2787 2788 2788 return document->renderView()->compositor().compositingUpdateCount(); 2789 2789 } … … 3077 3077 if (!document || !document->page()) 3078 3078 return Exception { INVALID_ACCESS_ERR }; 3079 3079 3080 3080 #if ENABLE(VIDEO_TRACK) 3081 3081 auto& captionPreferences = document->page()->group().captionPreferences(); 3082 3082 3083 3083 if (equalLettersIgnoringASCIICase(mode, "automatic")) 3084 3084 captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::Automatic); … … 3145 3145 return downcast<RenderEmbeddedObject>(*renderer).isReplacementObscured(); 3146 3146 } 3147 3147 3148 3148 bool Internals::isPluginSnapshotted(Element& element) 3149 3149 { 3150 3150 return is<HTMLPlugInElement>(element) && downcast<HTMLPlugInElement>(element).displayState() <= HTMLPlugInElement::DisplayingSnapshot; 3151 3151 } 3152 3152 3153 3153 #if ENABLE(MEDIA_SOURCE) 3154 3154 … … 3168 3168 return buffer.bufferedSamplesForTrackID(trackID); 3169 3169 } 3170 3170 3171 3171 Vector<String> Internals::enqueuedSamplesForTrackID(SourceBuffer& buffer, const AtomicString& trackID) 3172 3172 { … … 3208 3208 if (equalLettersIgnoringASCIICase(flagsString, "mayresumeplaying")) 3209 3209 flags = PlatformMediaSession::MayResumePlaying; 3210 3210 3211 3211 PlatformMediaSessionManager::sharedManager().endInterruption(flags); 3212 3212 } … … 3363 3363 else 3364 3364 return Exception { INVALID_ACCESS_ERR }; 3365 3365 3366 3366 PlatformMediaSessionManager::sharedManager().didReceiveRemoteControlCommand(command, ¶meter); 3367 3367 return { }; … … 3638 3638 else 3639 3639 justStarting = false; 3640 3640 3641 3641 builder.append(String::number(coordinate.toUnsigned())); 3642 3642 } 3643 3643 builder.appendLiteral(" }"); 3644 3644 } 3645 3645 3646 3646 void Internals::setPlatformMomentumScrollingPredictionEnabled(bool enabled) 3647 3647 { … … 3658 3658 RenderBox& box = *element.renderBox(); 3659 3659 ScrollableArea* scrollableArea; 3660 3660 3661 3661 if (box.isBody()) { 3662 3662 FrameView* frameView = box.frame().mainFrame().view(); … … 3664 3664 return Exception { INVALID_ACCESS_ERR }; 3665 3665 scrollableArea = frameView; 3666 3666 3667 3667 } else { 3668 3668 if (!box.canBeScrolledAndHasScrollableArea()) … … 3673 3673 if (!scrollableArea) 3674 3674 return String(); 3675 3675 3676 3676 StringBuilder result; 3677 3677 … … 3762 3762 if (!document) 3763 3763 return; 3764 3764 3765 3765 Page* page = document->page(); 3766 3766 if (!page) … … 3795 3795 } 3796 3796 3797 #if ENABLE(READABLE_BYTE_STREAM_API) 3798 3799 JSValue Internals::cloneArrayBuffer(JSC::ExecState& state, JSValue buffer, JSValue srcByteOffset, JSValue srcLength) 3800 { 3801 JSGlobalObject* globalObject = state.vmEntryGlobalObject(); 3802 JSVMClientData* clientData = static_cast<JSVMClientData*>(state.vm().clientData); 3803 const Identifier& privateName = clientData->builtinNames().cloneArrayBufferPrivateName(); 3804 JSValue value; 3805 PropertySlot propertySlot(value, PropertySlot::InternalMethodType::Get); 3806 globalObject->methodTable()->getOwnPropertySlot(globalObject, &state, privateName, propertySlot); 3807 value = propertySlot.getValue(&state, privateName); 3808 ASSERT(value.isFunction()); 3809 3810 JSObject* function = value.getObject(); 3811 CallData callData; 3812 CallType callType = JSC::getCallData(function, callData); 3813 ASSERT(callType != JSC::CallType::None); 3814 MarkedArgumentBuffer arguments; 3815 arguments.append(buffer); 3816 arguments.append(srcByteOffset); 3817 arguments.append(srcLength); 3818 3819 return JSC::call(&state, function, callType, callData, JSC::jsUndefined(), arguments); 3820 } 3821 3822 #endif 3797 3823 #endif 3798 3824 -
trunk/Source/WebCore/testing/Internals.h
r215263 r215322 196 196 void invalidateFontCache(); 197 197 void setFontSmoothingEnabled(bool); 198 198 199 199 ExceptionOr<void> setLowPowerModeEnabled(bool); 200 200 201 201 ExceptionOr<void> setScrollViewPosition(int x, int y); 202 202 203 203 ExceptionOr<Ref<ClientRect>> layoutViewportRect(); 204 204 ExceptionOr<Ref<ClientRect>> visualViewportRect(); 205 205 206 206 ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue); 207 207 … … 376 376 ExceptionOr<void> startTrackingLayerFlushes(); 377 377 ExceptionOr<unsigned> layerFlushCount(); 378 378 379 379 ExceptionOr<void> startTrackingStyleRecalcs(); 380 380 ExceptionOr<unsigned> styleRecalcCount(); … … 532 532 #if ENABLE(READABLE_STREAM_API) 533 533 bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue); 534 #if ENABLE(READABLE_BYTE_STREAM_API) 535 JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue); 536 #endif 534 537 #endif 535 538 536 539 String composedTreeAsText(Node&); 537 540 538 541 bool isProcessingUserGesture(); 539 542 double lastHandledUserGestureTimestamp(); … … 545 548 546 549 bool userPrefersReducedMotion() const; 547 550 548 551 void reportBacktrace(); 549 552 -
trunk/Source/WebCore/testing/Internals.idl
r215263 r215322 494 494 void setShowAllPlugins(boolean showAll); 495 495 496 [Conditional=READABLE_STREAM_API&READABLE_BYTE_STREAM_API, CallWith=ScriptState] any cloneArrayBuffer(any buffer, any srcByteOffset, any byteLength); 496 497 [Conditional=READABLE_STREAM_API, CallWith=ScriptState] boolean isReadableStreamDisturbed(any stream); 497 498
Note: See TracChangeset
for help on using the changeset viewer.