Changeset 214663 in webkit
- Timestamp:
- Mar 31, 2017, 3:37:06 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r214662 r214663 1 2017-03-31 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/readable-stream-byob-request.js: 11 1 12 2017-03-31 Oleksandr Skachkov <gskachkov@gmail.com> 2 13 -
trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt
r214265 r214663 11 11 PASS Calling respond() with a bytesWritten value greater than autoAllocateChunkSize should fail 12 12 PASS Calling respond() with a bytesWritten value lower than autoAllocateChunkSize should succeed 13 PASS Test cloneArrayBuffer implementation 13 14 PASS ReadableStreamBYOBRequest instances should have the correct list of properties 14 15 PASS By default, byobRequest should be undefined -
trunk/LayoutTests/streams/readable-stream-byob-request.js
r214265 r214663 242 242 // so that more code can be covered. 243 243 244 if (!self.importScripts) { 245 // Test only if not Worker. 246 const CloneArrayBuffer = internals.cloneArrayBuffer.bind(internals); 247 248 test(function() { 249 const typedArray = new Uint8Array([3, 5, 7]); 250 const clonedBuffer = CloneArrayBuffer(typedArray.buffer, 1, 1); 251 const otherArray = new Uint8Array(clonedBuffer); 252 assert_equals(otherArray.byteLength, 1); 253 assert_equals(otherArray.byteOffset, 0); 254 assert_equals(otherArray.buffer.byteLength, 1); 255 assert_equals(otherArray[0], 5); 256 // Check that when typedArray is modified, otherArray is not modified. 257 typedArray[1] = 0; 258 assert_equals(otherArray[0], 5); 259 }, "Test cloneArrayBuffer implementation"); 260 } 261 244 262 done(); -
trunk/Source/WebCore/ChangeLog
r214659 r214663 1 2017-03-31 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 Added test to check cloneArrayBuffer behaviour. 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-03-31 Antoine Quint <graouts@apple.com> 2 30 -
trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js
r214265 r214663 379 379 } 380 380 381 function cloneArrayBuffer(srcBuffer, srcByteOffset, srcLength)382 {383 "use strict";384 385 // FIXME: Below implementation returns the appropriate data but does not perform386 // exactly what is described by ECMAScript CloneArrayBuffer operation. This should387 // be fixed in a follow up patch implementing cloneArrayBuffer in JSC (similarly to388 // structuredCloneArrayBuffer implementation).389 return srcBuffer.slice(srcByteOffset, srcByteOffset + srcLength);390 }391 392 381 function readableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) 393 382 { -
trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp
r214080 r214663 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
r211403 r214663 36 36 namespace WebCore { 37 37 38 EncodedJSValue JSC_HOST_CALL structuredCloneArrayBuffer(ExecState* state) 38 EncodedJSValue JSC_HOST_CALL cloneArrayBufferImpl(ExecState*, bool); 39 40 EncodedJSValue JSC_HOST_CALL cloneArrayBufferImpl(ExecState* state, bool isPartialClone) 39 41 { 40 42 ASSERT(state); … … 49 51 return { }; 50 52 } 53 if (isPartialClone) { 54 ASSERT(state->argumentCount() == 3); 55 int srcByteOffset = static_cast<int>(state->uncheckedArgument(1).toNumber(state)); 56 int srcLength = static_cast<int>(state->uncheckedArgument(2).toNumber(state)); 57 buffer = buffer->slice(srcByteOffset, srcByteOffset + srcLength).get(); 58 } 51 59 return JSValue::encode(JSArrayBuffer::create(state->vm(), state->lexicalGlobalObject()->arrayBufferStructure(ArrayBufferSharingMode::Default), ArrayBuffer::tryCreate(buffer->data(), buffer->byteLength()))); 60 } 61 62 EncodedJSValue JSC_HOST_CALL cloneArrayBuffer(ExecState* state) 63 { 64 return cloneArrayBufferImpl(state, true); 65 } 66 67 EncodedJSValue JSC_HOST_CALL structuredCloneArrayBuffer(ExecState* state) 68 { 69 return cloneArrayBufferImpl(state, false); 52 70 } 53 71 -
trunk/Source/WebCore/bindings/js/StructuredClone.h
r205117 r214663 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
r214080 r214663 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
r214604 r214663 352 352 else 353 353 return false; 354 354 355 355 return true; 356 356 } … … 392 392 393 393 page.setDefersLoading(false); 394 394 395 395 page.mainFrame().setTextZoomFactor(1.0f); 396 396 397 397 FrameView* mainFrameView = page.mainFrame().view(); 398 398 if (mainFrameView) { … … 597 597 ResourceRequest request(contextDocument()->completeURL(url)); 598 598 request.setDomainForCachePartition(contextDocument()->topOrigin().domainForCachePartition()); 599 599 600 600 CachedResource* resource = MemoryCache::singleton().resourceForRequest(request, contextDocument()->page()->sessionID()); 601 601 return resource && resource->status() == CachedResource::Cached; … … 725 725 if (!cachedImage) 726 726 return; 727 727 728 728 auto* image = cachedImage->image(); 729 729 if (!is<BitmapImage>(image)) 730 730 return; 731 731 732 732 downcast<BitmapImage>(*image).setFrameDecodingDurationForTesting(duration); 733 733 } … … 989 989 continue; 990 990 } 991 991 992 992 StyleRuleGroup* groupRule = nullptr; 993 993 if (is<StyleRuleMedia>(rule.get())) … … 997 997 if (!groupRule) 998 998 continue; 999 999 1000 1000 auto* groupChildRules = groupRule->childRulesWithoutDeferredParsing(); 1001 1001 if (!groupChildRules) 1002 1002 continue; 1003 1003 1004 1004 count += deferredStyleRulesCountForList(*groupChildRules); 1005 1005 } … … 1024 1024 if (!groupRule) 1025 1025 continue; 1026 1026 1027 1027 auto* groupChildRules = groupRule->childRulesWithoutDeferredParsing(); 1028 1028 if (!groupChildRules) … … 1049 1049 continue; 1050 1050 } 1051 1051 1052 1052 StyleRuleGroup* groupRule = nullptr; 1053 1053 if (is<StyleRuleMedia>(rule.get())) … … 1057 1057 if (!groupRule) 1058 1058 continue; 1059 1059 1060 1060 auto* groupChildRules = groupRule->childRulesWithoutDeferredParsing(); 1061 1061 if (!groupChildRules) 1062 1062 continue; 1063 1063 1064 1064 count += deferredKeyframesRulesCountForList(*groupChildRules); 1065 1065 } 1066 1066 1067 1067 return count; 1068 1068 } … … 1137 1137 if (!behavior) 1138 1138 return std::nullopt; 1139 1139 1140 1140 switch (behavior.value()) { 1141 1141 case WebCore::EventThrottlingBehavior::Responsive: … … 1202 1202 if (!synthesis) 1203 1203 return; 1204 1204 1205 1205 synthesis->setPlatformSynthesizer(std::make_unique<PlatformSpeechSynthesizerMock>(synthesis)); 1206 1206 } … … 1634 1634 1635 1635 document->updateLayoutIgnorePendingStylesheets(); 1636 1636 1637 1637 HitTestResult result = document->frame()->mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y)); 1638 1638 NSDictionary *options = nullptr; … … 1790 1790 HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding); 1791 1791 renderView->hitTest(request, result); 1792 1792 1793 1793 const HitTestResult::NodeSet& nodeSet = result.rectBasedTestResult(); 1794 1794 matches.reserveInitialCapacity(nodeSet.size()); … … 1911 1911 return document->frame()->editor().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); 1912 1912 } 1913 1913 1914 1914 bool Internals::hasAutocorrectedMarker(int from, int length) 1915 1915 { … … 2164 2164 return count; 2165 2165 } 2166 2166 2167 2167 ExceptionOr<bool> Internals::isPageBoxVisible(int pageNumber) 2168 2168 { … … 2217 2217 if (!layerModelObject.layer()->isComposited()) 2218 2218 return Exception { NOT_FOUND_ERR }; 2219 2219 2220 2220 auto* backing = layerModelObject.layer()->backing(); 2221 2221 return backing->graphicsLayer()->primaryLayerID(); … … 2286 2286 if (!element.renderer()->hasLayer()) 2287 2287 return Exception { INVALID_ACCESS_ERR }; 2288 2288 2289 2289 RenderLayer* layer = downcast<RenderLayerModelObject>(element.renderer())->layer(); 2290 2290 if (!layer->isComposited()) 2291 2291 return Exception { INVALID_ACCESS_ERR }; 2292 2292 2293 2293 layer->backing()->setUsesDisplayListDrawing(usesDisplayListDrawing); 2294 2294 return { }; … … 2315 2315 if (!layer->isComposited()) 2316 2316 return Exception { INVALID_ACCESS_ERR }; 2317 2317 2318 2318 layer->backing()->setIsTrackingDisplayListReplay(isTrackingReplay); 2319 2319 return { }; … … 2555 2555 document->view()->setFooterHeight(height); 2556 2556 } 2557 2557 2558 2558 void Internals::setTopContentInset(float contentInset) 2559 2559 { … … 2699 2699 if (!document) 2700 2700 return Exception { INVALID_ACCESS_ERR }; 2701 2701 2702 2702 return document->styleRecalcCount(); 2703 2703 } … … 2726 2726 if (!document || !document->renderView()) 2727 2727 return Exception { INVALID_ACCESS_ERR }; 2728 2728 2729 2729 return document->renderView()->compositor().compositingUpdateCount(); 2730 2730 } … … 3018 3018 if (!document || !document->page()) 3019 3019 return Exception { INVALID_ACCESS_ERR }; 3020 3020 3021 3021 #if ENABLE(VIDEO_TRACK) 3022 3022 auto& captionPreferences = document->page()->group().captionPreferences(); 3023 3023 3024 3024 if (equalLettersIgnoringASCIICase(mode, "automatic")) 3025 3025 captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::Automatic); … … 3086 3086 return downcast<RenderEmbeddedObject>(*renderer).isReplacementObscured(); 3087 3087 } 3088 3088 3089 3089 bool Internals::isPluginSnapshotted(Element& element) 3090 3090 { 3091 3091 return is<HTMLPlugInElement>(element) && downcast<HTMLPlugInElement>(element).displayState() <= HTMLPlugInElement::DisplayingSnapshot; 3092 3092 } 3093 3093 3094 3094 #if ENABLE(MEDIA_SOURCE) 3095 3095 … … 3109 3109 return buffer.bufferedSamplesForTrackID(trackID); 3110 3110 } 3111 3111 3112 3112 Vector<String> Internals::enqueuedSamplesForTrackID(SourceBuffer& buffer, const AtomicString& trackID) 3113 3113 { … … 3149 3149 if (equalLettersIgnoringASCIICase(flagsString, "mayresumeplaying")) 3150 3150 flags = PlatformMediaSession::MayResumePlaying; 3151 3151 3152 3152 PlatformMediaSessionManager::sharedManager().endInterruption(flags); 3153 3153 } … … 3302 3302 else 3303 3303 return Exception { INVALID_ACCESS_ERR }; 3304 3304 3305 3305 PlatformMediaSessionManager::sharedManager().didReceiveRemoteControlCommand(command, ¶meter); 3306 3306 return { }; … … 3573 3573 else 3574 3574 justStarting = false; 3575 3575 3576 3576 builder.append(String::number(coordinate.toUnsigned())); 3577 3577 } 3578 3578 builder.appendLiteral(" }"); 3579 3579 } 3580 3580 3581 3581 void Internals::setPlatformMomentumScrollingPredictionEnabled(bool enabled) 3582 3582 { … … 3593 3593 RenderBox& box = *element.renderBox(); 3594 3594 ScrollableArea* scrollableArea; 3595 3595 3596 3596 if (box.isBody()) { 3597 3597 FrameView* frameView = box.frame().mainFrame().view(); … … 3599 3599 return Exception { INVALID_ACCESS_ERR }; 3600 3600 scrollableArea = frameView; 3601 3601 3602 3602 } else { 3603 3603 if (!box.canBeScrolledAndHasScrollableArea()) … … 3608 3608 if (!scrollableArea) 3609 3609 return String(); 3610 3610 3611 3611 StringBuilder result; 3612 3612 … … 3697 3697 if (!document) 3698 3698 return; 3699 3699 3700 3700 Page* page = document->page(); 3701 3701 if (!page) … … 3730 3730 } 3731 3731 3732 #if ENABLE(READABLE_BYTE_STREAM_API) 3733 3734 JSValue Internals::cloneArrayBuffer(JSC::ExecState& state, JSValue buffer, JSValue srcByteOffset, JSValue srcLength) 3735 { 3736 JSGlobalObject* globalObject = state.vmEntryGlobalObject(); 3737 JSVMClientData* clientData = static_cast<JSVMClientData*>(state.vm().clientData); 3738 const Identifier& privateName = clientData->builtinNames().cloneArrayBufferPrivateName(); 3739 JSValue value; 3740 PropertySlot propertySlot(value, PropertySlot::InternalMethodType::Get); 3741 globalObject->methodTable()->getOwnPropertySlot(globalObject, &state, privateName, propertySlot); 3742 value = propertySlot.getValue(&state, privateName); 3743 ASSERT(value.isFunction()); 3744 3745 JSObject* function = value.getObject(); 3746 CallData callData; 3747 CallType callType = JSC::getCallData(function, callData); 3748 ASSERT(callType != JSC::CallType::None); 3749 MarkedArgumentBuffer arguments; 3750 arguments.append(buffer); 3751 arguments.append(srcByteOffset); 3752 arguments.append(srcLength); 3753 3754 return JSC::call(&state, function, callType, callData, JSC::jsUndefined(), arguments); 3755 } 3756 3757 #endif 3732 3758 #endif 3733 3759 -
trunk/Source/WebCore/testing/Internals.h
r214604 r214663 189 189 void invalidateFontCache(); 190 190 void setFontSmoothingEnabled(bool); 191 191 192 192 ExceptionOr<void> setLowPowerModeEnabled(bool); 193 193 194 194 ExceptionOr<void> setScrollViewPosition(int x, int y); 195 195 196 196 ExceptionOr<Ref<ClientRect>> layoutViewportRect(); 197 197 ExceptionOr<Ref<ClientRect>> visualViewportRect(); 198 198 199 199 ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue); 200 200 … … 369 369 ExceptionOr<void> startTrackingLayerFlushes(); 370 370 ExceptionOr<unsigned> layerFlushCount(); 371 371 372 372 ExceptionOr<void> startTrackingStyleRecalcs(); 373 373 ExceptionOr<unsigned> styleRecalcCount(); … … 524 524 #if ENABLE(READABLE_STREAM_API) 525 525 bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue); 526 #if ENABLE(READABLE_BYTE_STREAM_API) 527 JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue); 528 #endif 526 529 #endif 527 530 528 531 String composedTreeAsText(Node&); 529 532 530 533 bool isProcessingUserGesture(); 531 534 … … 536 539 537 540 bool userPrefersReducedMotion() const; 538 541 539 542 void reportBacktrace(); 540 543 -
trunk/Source/WebCore/testing/Internals.idl
r214604 r214663 491 491 void setShowAllPlugins(boolean showAll); 492 492 493 [Conditional=READABLE_STREAM_API&READABLE_BYTE_STREAM_API, CallWith=ScriptState] any cloneArrayBuffer(any buffer, any srcByteOffset, any byteLength); 493 494 [Conditional=READABLE_STREAM_API, CallWith=ScriptState] boolean isReadableStreamDisturbed(any stream); 494 495
Note:
See TracChangeset
for help on using the changeset viewer.