2015-07-23 Alexey Proskuryakov Merge r186677, which is a follow-up fix to r186642. 2015-07-10 Brady Eidson ASSERT restoring from page cache as DocumentLoader reattaches to its Frame. and https://bugs.webkit.org/show_bug.cgi?id=146786 Reviewed by NOBODY (Fixing obvious boneheaded mistake in r186642) No new tests (Covered by existing) * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::attachToFrame): Bail if reattaching to the current Frame, which happens when restoring from the page cache. 2015-07-22 Babak Shafiei Merge r187183. 2015-07-22 Jeremy Jones Fix fullscreen and PiP video animation and sizing regressions. https://bugs.webkit.org/show_bug.cgi?id=147189 Reviewed by Jer Noble. Fixes WK1 specific regressions introduced by r187044. Flicker when entering fullscreen, wrong animation and missing initial animation rects. * platform/ios/WebVideoFullscreenControllerAVKit.mm: (elementRectInWindow): Added. (WebVideoFullscreenControllerContext::didSetupFullscreen): Clear background decreases flash. (WebVideoFullscreenControllerContext::fullscreenMayReturnToInline): Use consistent inline rect. (WebVideoFullscreenControllerContext::setVideoLayerFrame): Clear the transform on the web thread instead of on the UI thread. (WebVideoFullscreenControllerContext::setUpFullscreen): Use consistent inline rect. (WebVideoFullscreenControllerContext::exitFullscreen): Use consistent inline rect. * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: (-[WebAVPlayerLayer resolveBounds]): Clear transform after setting frame. 2015-07-22 Babak Shafiei Merge r187181. 2015-07-22 Jeremy Jones Adopt AVKit's AVSimplePlayerLayerView change for PiP. https://bugs.webkit.org/show_bug.cgi?id=147186 Reviewed by Jer Noble. Adopt AVKit changes by inheriting from UIView instead of from AVPictureInPicturePlayerLayerView. * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: (WebAVPlayerLayerView_layerClass): Style. (WebAVPlayerLayerView_playerController): Style. (WebAVPlayerLayerView_videoView): Style. (getWebAVPictureInPicturePlayerLayerViewClass): Inherit from UIView. 2015-07-21 Alexey Proskuryakov Merge r186980. 2015-07-17 Simon Fraser Attempt to fix the build. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless): * html/HTMLMediaElement.h: 2015-07-21 Babak Shafiei Merge r187128. 2015-07-21 Tim Horton Placing video in fullscreen caused WebKit crash at WebCore::Range::textQuads https://bugs.webkit.org/show_bug.cgi?id=147166 Reviewed by Simon Fraser. * editing/FrameSelection.cpp: (WebCore::FrameSelection::getClippedVisibleTextRectangles): Check the Range, as always. 2015-07-20 Matthew Hanson Merge r187098. rdar://problem/21878275 2015-07-20 Ada Chan Follow-up to my earlier fix for r147085 https://bugs.webkit.org/show_bug.cgi?id=147085 Reviewed by Eric Carlson. * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::isPlayingAudioDidChange): Null-check document() before dereferencing it in case the audio context's document is destroyed by the time the code block is called on the main thread. 2015-07-20 Matthew Hanson Merge r187053. rdar://problem/21778212 2015-07-20 Nan Wang AX: Selection change as a result of focusing an element may cause Safari to crash https://bugs.webkit.org/show_bug.cgi?id=147052 Reviewed by Chris Fleizach. When focusing an element, it may trigger a deferred layout that invalidates the render element, which will cause axObjectCache() to be a nullptr, and lead to a crash. Fix that by using a RefPtr to hold the object and also caching the axObjectCache(). Test: platform/mac/accessibility/focus-crash.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::setFocused): (WebCore::AccessibilityRenderObject::setSelectedRows): 2015-07-20 Matthew Hanson Merge r187044. rdar://problem/21661808 2015-07-20 Jeremy Jones Adopt AVPlayerLayerView https://bugs.webkit.org/show_bug.cgi?id=146862 Reviewed by Jer Noble. The CALayerHost is replaced with WebLayerHostView to be compatible with UIView animations. Some animation is improved in the conversion. WebAVPlayerLayerView and WebAVPictureInPicturePlayerLayerView derive from AVKit and UIKit respectively. Because these frameworks are loaded at runtime, these classes must be generate using objc/runtime.h to register them from c functions at runtime. The most important part of these UIViews is that their backing layer is a WebAVPlayerLayer. WebCALayerHostWrapper and WebAVVideoLayer are combined into WebAVPlayerLayer to simplify the hierarchy. WebAVPlayerLayer is a stand-in for an AVPlayerLayer. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer): -removeFromSuperlayer is redundant. (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenGravity): syncTextTrackBounds on change. (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame): We never want animation here, since all animation will happen in UIViews. This is just for going into the final size after a transform based animation. * platform/ios/WebVideoFullscreenControllerAVKit.mm: (WebVideoFullscreenControllerContext::didSetupFullscreen): layer -> view (WebVideoFullscreenControllerContext::didCleanupFullscreen): layer -> view (WebVideoFullscreenControllerContext::setUpFullscreen): layer -> view (WebVideoFullscreenControllerContext::setVideoLayerFrame): layer -> view Use fence port to synchronize between the UIThread and the WebThread, the same way WebKit2 uses a fence port to synchronize between processes. (WebVideoFullscreenControllerContext::setVideoLayerGravity): No longer necessary to cache videoGravity at this level. * platform/ios/WebVideoFullscreenInterfaceAVKit.h: * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: (-[WebAVPlayerLayer init]): (-[WebAVPlayerLayer dealloc]): (-[WebAVPlayerLayer playerController]): (-[WebAVPlayerLayer setBounds:]): (-[WebAVPlayerLayer resolveBounds]): (-[WebAVPlayerLayer setVideoGravity:]): (-[WebAVPlayerLayer videoGravity]): (-[WebAVPlayerLayer videoRect]): (+[WebAVPlayerLayer keyPathsForValuesAffectingVideoRect]): Added class WebAVPlayerLayer, replacing WebAVVideoLayer and WebCALayerHostWrapper. (WebAVPictureInPicturePlayerLayerView_layerClass): (getWebAVPictureInPicturePlayerLayerViewClass): Added runtime class WebAVPictureInPicturePlayerLayerView (WebAVPlayerLayerView_layerClass): (WebAVPlayerLayerView_playerController): (WebAVPlayerLayerView_setPlayerController): (WebAVPlayerLayerView_videoView): (WebAVPlayerLayerView_setVideoView): (WebAVPlayerLayerView_startRoutingVideoToPictureInPicturePlayerLayerView): (WebAVPlayerLayerView_stopRoutingVideoToPictureInPicturePlayerLayerView): (WebAVPlayerLayerView_pictureInPicturePlayerLayerView): (getWebAVPlayerLayerViewClass): Added runtime class WebAVPlayerLayerView (WebVideoFullscreenInterfaceAVKit::setVideoDimensions): Dimensions are also stored in WebAVPlayerLayer so it can make decisions about animating the video layer. (WebVideoFullscreenInterfaceAVKit::setExternalPlayback): (WebVideoFullscreenInterfaceAVKit::enterFullscreen): (WebVideoFullscreenInterfaceAVKit::didStopPictureInPicture): (WebVideoFullscreenInterfaceAVKit::cleanupFullscreen): Straightforward layer to view conversion. (WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline): Set view frame using the view hierarchy instead of assuming it is directly in a window. (WebVideoFullscreenInterfaceAVKit::exitFullscreen): Set view frame using the view hierarchy instead of assuming it is directly in a window. dispatch_async before calling didExitFullscreen() to allows CATransactions to complete. (WebVideoFullscreenInterfaceAVKit::setupFullscreen): Set view frame using the view hierarchy instead of assuming it is directly in a window. dispatch_async before calling didSetupFullscreen() to allows CATransactions to complete. (-[WebCALayerHostWrapper dealloc]): Deleted. (-[WebCALayerHostWrapper setVideoSublayer:]): Deleted. (-[WebCALayerHostWrapper videoSublayer]): Deleted. (-[WebCALayerHostWrapper setBounds:]): Deleted. (-[WebCALayerHostWrapper resolveBounds]): Deleted. Class WebCALayerHostWrapper deleted. Functionality rolled into WebAVPlayerLayer. (+[WebAVVideoLayer videoLayer]): Deleted. (-[WebAVVideoLayer init]): Deleted. (-[WebAVVideoLayer setPlayerViewController:]): Deleted. (-[WebAVVideoLayer setVideoSublayer:]): Deleted. (-[WebAVVideoLayer setBounds:]): Deleted. (-[WebAVVideoLayer setVideoLayerGravity:]): Deleted. (-[WebAVVideoLayer videoLayerGravity]): Deleted. (-[WebAVVideoLayer enterPIPModeRedirectingVideoToLayer:]): Deleted. (-[WebAVVideoLayer leavePIPMode]): Deleted. Class WebAVVideoLayer deleted. Functionality rolled into WebAVPlayerLayer. * platform/ios/WebVideoFullscreenModel.h: * platform/ios/WebVideoFullscreenModelVideoElement.h: * platform/ios/WebVideoFullscreenModelVideoElement.mm: No need to store frame and gravity in the model. It is stored in the UI where it is used. (WebVideoFullscreenModelVideoElement::videoLayerFrame): Deleted. (WebVideoFullscreenModelVideoElement::videoLayerGravity): Deleted. * platform/spi/cocoa/AVKitSPI.h: Add AVPlayerLayerView. 2015-07-20 Matthew Hanson Merge r187039. rdar://problem/21474317 2015-07-20 Tim Horton REGRESSION (r174287): Flash of black when opening a new web view or navigating to a new page https://bugs.webkit.org/show_bug.cgi?id=147127 Reviewed by Simon Fraser. * rendering/RenderView.cpp: (WebCore::RenderView::paintBoxDecorations): Avoid using an invalid documentBackgroundColor, fall back to baseBackgroundColor like we did before r174287. 2015-07-20 Matthew Hanson Merge r186910. rdar://problem/21863296 2015-07-16 Benjamin Poulain [Content extensions] Combine suffixes when generating NFAs https://bugs.webkit.org/show_bug.cgi?id=146961 Reviewed by Alex Christensen. In this patch, I add a mechanism very similar to the prefix tree but for the suffix (called a reverse suffix tree here). The idea is here is to reuse the existing NFA nodes when generating a chain of suffix Term that were already generated previously. When generating a disjunction ending with the same suffix, we now have the same trailing NFA nodes for both sides of the disjunction. Mixing the prefix and suffix generation can be tricky, we do not want transitions from a pattern to creep into the suffix of an other. To avoid any conflict, the rules here are very simple: -Only use the reverse suffix tree for terms without actions up to a leaf term with actions. This rule ensure that no action will accidentally make its way to an other rule by resuing a vertex of the reverse suffix tree. -Only use the reverse suffix tree for chains of terms in which each term only has zero or one following term. With this condition, when taking any vertex of the reverse suffix tree, there is only one edge that move out of that vertex when reading from left to right. For any vertex, there is only one possible string generated left-to-right, a single suffix. This is overly restrictive but it is fast, easier to verify, and it works well in practice. For all the more complicated cases, we can count on the Minimizer to find a better solution. With all the simple suffixes merged, our NFAs are smaller, which let us combine more patterns. The DFAs are also smaller and faster to produce since their size is relative to the NFA sizes. Overall, I get the following gains: -Chris's test case: compile time -40%. bytecode size -14%. -Armand's test case: compile time -53%. bytecode size -13%. * WebCore.xcodeproj/project.pbxproj: * contentextensions/CombinedURLFilters.cpp: (WebCore::ContentExtensions::ActiveSubtree::ActiveSubtree): (WebCore::ContentExtensions::generateInfixUnsuitableForReverseSuffixTree): (WebCore::ContentExtensions::generateSuffixWithReverseSuffixTree): (WebCore::ContentExtensions::clearReverseSuffixTree): (WebCore::ContentExtensions::generateNFAForSubtree): * contentextensions/DFA.cpp: (WebCore::ContentExtensions::DFA::debugPrintDot): Forgot to close a tag, dot was not happy. * contentextensions/HashableActionList.h: Added. (WebCore::ContentExtensions::HashableActionList::HashableActionList): (WebCore::ContentExtensions::HashableActionList::isEmptyValue): (WebCore::ContentExtensions::HashableActionList::isDeletedValue): (WebCore::ContentExtensions::HashableActionList::operator==): (WebCore::ContentExtensions::HashableActionList::operator!=): (WebCore::ContentExtensions::HashableActionListHash::hash): (WebCore::ContentExtensions::HashableActionListHash::equal): We need a way to group reverse suffix tree by their terminal actions. This new hash structure lets us find unique vertex for a list of actions in any order. * contentextensions/ImmutableNFANodeBuilder.h: (WebCore::ContentExtensions::ImmutableNFANodeBuilder::isValid): (WebCore::ContentExtensions::ImmutableNFANodeBuilder::nodeId): (WebCore::ContentExtensions::ImmutableNFANodeBuilder::addTransition): (WebCore::ContentExtensions::ImmutableNFANodeBuilder::addEpsilonTransition): (WebCore::ContentExtensions::ImmutableNFANodeBuilder::ImmutableNFANodeBuilder): Deleted. (WebCore::ContentExtensions::ImmutableNFANodeBuilder::~ImmutableNFANodeBuilder): Deleted. (WebCore::ContentExtensions::ImmutableNFANodeBuilder::operator=): Deleted. * contentextensions/Term.h: (WebCore::ContentExtensions::Term::generateGraph): (WebCore::ContentExtensions::Term::generateSubgraphForAtom): Node building changes a bit. Previously, it was assumed nodes are always built from left to right. Getting the node on the right was done by providing the left node and the term doing the transition. Now we have both left to right and right to left generation. The right-to-left has a specific property: no edge can be added after it's initial term (rule 2 of our reverse suffix tree). This simplifies things a bit since we can finalize all the nodes in the suffix tree. All we need is to keep their ID to be able to link new nodes to the reverse suffix tree. 2015-07-20 Matthew Hanson Merge r186715. rdar://problem/21863296 2015-07-11 Benjamin Poulain Fix CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING https://bugs.webkit.org/show_bug.cgi?id=146879 Reviewed by Andreas Kling. Some of my recent changes broke CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING :( * contentextensions/CombinedURLFilters.cpp: (WebCore::ContentExtensions::prefixTreeVertexToString): (WebCore::ContentExtensions::recursivePrint): (WebCore::ContentExtensions::CombinedURLFilters::print): * contentextensions/ContentExtensionsDebugging.h: * contentextensions/DFA.cpp: (WebCore::ContentExtensions::DFA::debugPrintDot): 2015-07-20 Matthew Hanson Merge r186955. rdar://problem/14489674 2015-07-17 Mark Lam Remove leak of objects between isolated worlds on custom events, message events, and pop state events. https://bugs.webkit.org/show_bug.cgi?id=118884 Reviewed by Filip Pizlo and Mark Lam. Patch by Keith Miller . Tests: fast/events/event-leak-objects.html fast/events/event-properties-gc.html Fixes an issue where objects passed as certain properties of events could cross isolated worlds. This was fixed by checking that any object passed by an event must be serializable or originate from the same isolated world as the one it is currently being accessed in. In the case of MessageEvents and PopStateEvents we cache the values of the data and state properties, respectively, as they may be a deserialized object. In case an object was deserialized in a world with elevated privileges we also check the cached value is from the same world, if it is from a different world we recompute it. For testing purposes, I added a new function to Internals that determines whether a JSObject originated in the current world. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/DOMWrapperWorld.h: (WebCore::worldForDOMObject): * bindings/js/JSBindingsAllInOne.cpp: * bindings/js/JSCustomEventCustom.cpp: Copied from Source/WebCore/dom/CustomEvent.cpp. (WebCore::JSCustomEvent::detail): * bindings/js/JSMessageEventCustom.cpp: (WebCore::JSMessageEvent::data): * bindings/js/JSPopStateEventCustom.cpp: (WebCore::JSPopStateEvent::state): * dom/CustomEvent.cpp: (WebCore::CustomEvent::initCustomEvent): (WebCore::CustomEvent::trySerializeDetail): * dom/CustomEvent.h: * dom/CustomEvent.idl: * dom/MessageEvent.cpp: (WebCore::MessageEvent::initMessageEvent): (WebCore::MessageEvent::trySerializeData): * dom/MessageEvent.h: * dom/PopStateEvent.cpp: (WebCore::PopStateEvent::trySerializeState): * dom/PopStateEvent.h: * testing/Internals.cpp: (WebCore::Internals::isFromCurrentWorld): * testing/Internals.h: * testing/Internals.idl: 2015-07-20 Matthew Hanson Merge r187035. rdar://problem/21712311 2015-07-20 Andreas Kling Unreviewed assertion fix following r187031. Just have GenericEventQueue::resume() return early if the queue isn't suspended. Suspend/Resume calls are not always symmetrical in HTMLMediaElement. * dom/GenericEventQueue.cpp: (WebCore::GenericEventQueue::resume): 2015-07-20 Matthew Hanson Merge r187031. rdar://problem/21712311 2015-07-20 Andreas Kling Improve behavior of media elements in page cache. Reviewed by Chris Dumez. Make improvements for media elements when transitioning in/out of page cache: - Events that were scheduled when going into cache will now be delivered when the page is restored from cache. - Data buffering is turned off while in the cache. This reduces the memory cost of cached pages with media elements on iOS (where mediaserverd would keep upcoming video frames in memory for cached pages.) Test: media/restore-from-page-cache.html (amended) * dom/GenericEventQueue.h: * dom/GenericEventQueue.cpp: (WebCore::GenericEventQueue::enqueueEvent): (WebCore::GenericEventQueue::suspend): (WebCore::GenericEventQueue::resume): Add a simple suspend/resume mechanism to GenericEventQueue that can be used to support page caching. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::stop): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer): Adapt to event queueing changes and add calls to setShouldBufferData(). * html/HTMLSourceElement.h: * html/HTMLSourceElement.cpp: (WebCore::HTMLSourceElement::HTMLSourceElement): (WebCore::HTMLSourceElement::create): (WebCore::HTMLSourceElement::activeDOMObjectName): (WebCore::HTMLSourceElement::canSuspendForPageCache): (WebCore::HTMLSourceElement::suspend): (WebCore::HTMLSourceElement::resume): (WebCore::HTMLSourceElement::stop): Turn HTMLSourceElement into an ActiveDOMObject so it gets all the appropriate page cache notifications directly. Suspend the delayed error event delivery timer when cached. 2015-07-20 Matthew Hanson Merge r187025. rdar://problem/21878275 2015-07-18 Ada Chan Fix deadlock between -[AVPlayerItem currentTime] and -[AVPlayer isExternalPlaybackActive] https://bugs.webkit.org/show_bug.cgi?id=147085 Reviewed by Jer Noble. * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::isPlayingAudioDidChange): Call Document::updateIsPlayingMedia() on the main thread, since we could be on the audio I/O thread here and the Document::updateIsPlayingMedia() call could block, causing a deadlock. 2015-07-20 Matthew Hanson Merge r186991. rdar://problem/21643094 2015-07-18 David Kilzer REGRESSION (r186976): Use piFloat instead of M_PI Attempt to fix the following build failure: PathUtilities.cpp(183): error C2065: 'M_PI' : undeclared identifier [...\Source\WebCore\WebCore.vcxproj\WebCore.vcxproj] * platform/graphics/PathUtilities.cpp: (WebCore::walkGraphAndExtractPolygon): Use piFloat since M_PI is not defined on Windows. 2015-07-20 Matthew Hanson Merge r186990. rdar://problem/21643094 2015-07-18 David Kilzer REGRESSION (r186976): Windows build broke due to missing definition of M_PI Attempt to fix the following build failure: PathUtilities.cpp(182): error C2065: 'M_PI' : undeclared identifier [...\Source\WebCore\WebCore.vcxproj\WebCore.vcxproj] * platform/graphics/PathUtilities.cpp: Include . 2015-07-20 Matthew Hanson Merge r186982. rdar://problem/21567820 2015-07-17 Andy Estes [iOS] Further tighten the sandbox around pages fetched with Content-Disposition: attachment https://bugs.webkit.org/show_bug.cgi?id=147044 rdar://problem/21567820 Reviewed by Brady Eidson. In addition to placing resources fetched with 'Content-Disposition: attachment' in a unique origin, this change does the following: - Switches the sandbox type from SandboxOrigin to SandboxAll, which enforces the same restrictions as