2018-08-16 Kocsen Chung Cherry-pick r234890. rdar://problem/43385599 Remove failing assertion introduced in r234873 https://bugs.webkit.org/show_bug.cgi?id=188581 * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): The assertion is correct but failing because VectorTraits is incorrect. I'll re-add it and fix VectorTraits in a separate patch. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234890 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2018-08-15 Alex Christensen Remove failing assertion introduced in r234873 https://bugs.webkit.org/show_bug.cgi?id=188581 * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): The assertion is correct but failing because VectorTraits is incorrect. I'll re-add it and fix VectorTraits in a separate patch. 2018-08-16 Kocsen Chung Cherry-pick r234873. rdar://problem/43385599 isValidCSSSelector is unsafe to be called from a non-main thread https://bugs.webkit.org/show_bug.cgi?id=188581 Reviewed by Sam Weinig. Source/WebCore: Parsing and determining whether the css selectors are valid is fast enough to do before hopping to the background thread for the slow NFA/DFA operations and writing to disk. Doing it on the main thread avoids the thread safety issues in the CSSParser's use of strings. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::isValidCSSSelector): (WebCore::ContentExtensions::loadEncodedRules): (WebCore::ContentExtensions::parseRuleList): * contentextensions/ContentExtensionParser.h: * contentextensions/ContentExtensionRule.cpp: (WebCore::ContentExtensions::Trigger::isolatedCopy const): (WebCore::ContentExtensions::Action::isolatedCopy const): * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::Trigger::isEmpty const): (WebCore::ContentExtensions::Trigger::operator== const): (WebCore::ContentExtensions::Action::Action): (WebCore::ContentExtensions::ContentExtensionRule::isolatedCopy const): (WebCore::ContentExtensions::ContentExtensionRule::operator== const): (WebCore::ContentExtensions::vectorIsolatedCopy): Source/WebKit: * UIProcess/API/APIContentRuleListStore.cpp: (API::compiledToFile): (API::ContentRuleListStore::lookupContentRuleList): (API::ContentRuleListStore::getAvailableContentRuleListIdentifiers): (API::ContentRuleListStore::compileContentRuleList): (API::ContentRuleListStore::removeContentRuleList): (API::ContentRuleListStore::getContentRuleListSource): * UIProcess/API/APIContentRuleListStore.h: * UIProcess/API/Cocoa/WKContentRuleListStore.mm: Source/WTF: * wtf/Vector.h: (WTF::minCapacity>::isolatedCopy): Tools: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: (TestWebKitAPI::InMemoryCompiledContentExtension::create): (TestWebKitAPI::checkCompilerError): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234873 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2018-08-14 Alex Christensen isValidCSSSelector is unsafe to be called from a non-main thread https://bugs.webkit.org/show_bug.cgi?id=188581 Reviewed by Sam Weinig. Parsing and determining whether the css selectors are valid is fast enough to do before hopping to the background thread for the slow NFA/DFA operations and writing to disk. Doing it on the main thread avoids the thread safety issues in the CSSParser's use of strings. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::isValidCSSSelector): (WebCore::ContentExtensions::loadEncodedRules): (WebCore::ContentExtensions::parseRuleList): * contentextensions/ContentExtensionParser.h: * contentextensions/ContentExtensionRule.cpp: (WebCore::ContentExtensions::Trigger::isolatedCopy const): (WebCore::ContentExtensions::Action::isolatedCopy const): * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::Trigger::isEmpty const): (WebCore::ContentExtensions::Trigger::operator== const): (WebCore::ContentExtensions::Action::Action): (WebCore::ContentExtensions::ContentExtensionRule::isolatedCopy const): (WebCore::ContentExtensions::ContentExtensionRule::operator== const): (WebCore::ContentExtensions::vectorIsolatedCopy): 2018-08-15 Babak Shafiei Cherry-pick r234905. rdar://problem/43347925 Can't share an app on AppStore to WeChat due to a release assert https://bugs.webkit.org/show_bug.cgi?id=188621 Reviewed by Geoffrey Garen. Disable the thread safety check when the app is not linked on or after iOS 12 since this release assert is getting hit by third party applications on iOS in UI process. Source/WebCore: * platform/Timer.cpp: (WebCore::shouldSuppressThreadSafetyCheck): Added a SDK check. Source/WebKit: * UIProcess/Cocoa/VersionChecks.h: (WebKit::SDKVersion::FirstWithMainThreadReleaseAssertionInWebPageProxy): Added. It's iOS 12 or macOS 10.14 Mojave. * UIProcess/WebProcessProxy.cpp: (WebKit::isMainThreadOrCheckDisabled): Added. Returns true whether when we're in the main thread or if the app is not linked on or after iOS 12 or macOS 10.14 Mojave. (WebKit::globalPageMap): (WebKit::m_isInPrewarmedPool): (WebKit::WebProcessProxy::~WebProcessProxy): (WebKit::WebProcessProxy::shutDown): (WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): (WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData): (WebKit::WebProcessProxy::didFinishLaunching): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234905 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2018-08-15 Ryosuke Niwa Can't share an app on AppStore to WeChat due to a release assert https://bugs.webkit.org/show_bug.cgi?id=188621 Reviewed by Geoffrey Garen. Disable the thread safety check when the app is not linked on or after iOS 12 since this release assert is getting hit by third party applications on iOS in UI process. * platform/Timer.cpp: (WebCore::shouldSuppressThreadSafetyCheck): Added a SDK check. 2018-08-13 Kocsen Chung Cherry-pick r234766. rdar://problem/43240328 CrashTracer: com.apple.WebKit.Storage at WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose https://bugs.webkit.org/show_bug.cgi?id=188461 Reviewed by Chris Dumez. When we try to schedule shutdown for database, we should cancel the timer so no scheduleShutdownForClose will be running after this. * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234766 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2018-08-10 Sihui Liu CrashTracer: com.apple.WebKit.Storage at WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose https://bugs.webkit.org/show_bug.cgi?id=188461 Reviewed by Chris Dumez. When we try to schedule shutdown for database, we should cancel the timer so no scheduleShutdownForClose will be running after this. * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): 2018-08-13 Kocsen Chung Cherry-pick r234778. rdar://problem/43240324 [macOS] Multiple third party apps crash due to the thread safety check in TimerBase::setNextFireTime https://bugs.webkit.org/show_bug.cgi?id=188480 Reviewed by Simon Fraser. Source/WebCore: Suppress the release assert in WebKit1 on macOS (isInWebProcess is always true in non-Cocoa platforms). In the future, we should consider throwing Objective-C exceptions when third party apps call WebKit1 or WebKit2 APIs in non-main threads. * platform/Timer.cpp: (WebCore::shouldSuppressThreadSafetyCheck): Extracted out of ~TimerBase and setNextFireTime. (WebCore::TimerBase::~TimerBase): (WebCore::TimerBase::setNextFireTime): Source/WTF: Added the SDK version for macOS Mojave. * wtf/spi/darwin/dyldSPI.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234778 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2018-08-10 Ryosuke Niwa [macOS] Multiple third party apps crash due to the thread safety check in TimerBase::setNextFireTime https://bugs.webkit.org/show_bug.cgi?id=188480 Reviewed by Simon Fraser. Suppress the release assert in WebKit1 on macOS (isInWebProcess is always true in non-Cocoa platforms). In the future, we should consider throwing Objective-C exceptions when third party apps call WebKit1 or WebKit2 APIs in non-main threads. * platform/Timer.cpp: (WebCore::shouldSuppressThreadSafetyCheck): Extracted out of ~TimerBase and setNextFireTime. (WebCore::TimerBase::~TimerBase): (WebCore::TimerBase::setNextFireTime): 2018-08-09 Kocsen Chung Cherry-pick r234718. rdar://problem/43102434 REGRESSION (r228260): Events handled by input method invoke default event handler https://bugs.webkit.org/show_bug.cgi?id=188370 Reviewed by Wenson Hsieh. Source/WebCore: The bug was caused by the default event handler being invoked for the "virtual" keydown events generated for input methods. Namely, when Japanese or Chinese input methods swallows TAB key, WebKit should not invoke the default event handler and move the focus during input composition. Fixed the bug by adding a new boolean on Event indicating whether the default event handler should be invoked, and restoring the behavior prior to r228260 for these virtual keydown events. Test: editing/input/press-tab-during-ime-composition.html * dom/Event.h: (WebCore::Event::isDefaultEventHandlerIgnored const): Added. (WebCore::Event::setIsDefaultEventHandlerIgnored): Added. * dom/EventDispatcher.cpp: (WebCore::EventDispatcher::dispatchEvent): Don't invoke the default event handler if isDefaultEventHandlerIgnored is set. * page/EventHandler.cpp: (WebCore::EventHandler::internalKeyEvent): Set isDefaultEventHandlerIgnored. This restores WebKit's behavior prior to r228260. LayoutTests: Added a regression test. Due to the lack of adequate support of textInputController in WebKitTestRunner, the test is only enabled in WebKit1. The WTR fix is tracked by https://webkit.org/b/188428. * editing/input/press-tab-during-ime-composition-expected.txt: Added. * editing/input/press-tab-during-ime-composition.html: Added. * platform/ios/TestExpectations: * platform/wk2/TestExpectations: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234718 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2018-08-08 Ryosuke Niwa REGRESSION (r228260): Events handled by input method invoke default event handler https://bugs.webkit.org/show_bug.cgi?id=188370 Reviewed by Wenson Hsieh. The bug was caused by the default event handler being invoked for the "virtual" keydown events generated for input methods. Namely, when Japanese or Chinese input methods swallows TAB key, WebKit should not invoke the default event handler and move the focus during input composition. Fixed the bug by adding a new boolean on Event indicating whether the default event handler should be invoked, and restoring the behavior prior to r228260 for these virtual keydown events. Test: editing/input/press-tab-during-ime-composition.html * dom/Event.h: (WebCore::Event::isDefaultEventHandlerIgnored const): Added. (WebCore::Event::setIsDefaultEventHandlerIgnored): Added. * dom/EventDispatcher.cpp: (WebCore::EventDispatcher::dispatchEvent): Don't invoke the default event handler if isDefaultEventHandlerIgnored is set. * page/EventHandler.cpp: (WebCore::EventHandler::internalKeyEvent): Set isDefaultEventHandlerIgnored. This restores WebKit's behavior prior to r228260. 2018-08-03 Babak Shafiei Cherry-pick r234534. rdar://problem/42902608 Control center controls disappear when pausing, locking device. https://bugs.webkit.org/show_bug.cgi?id=188282 Reviewed by Eric Carlson. Source/WebCore: Test: platform/mac/media/audio-session-category-video-paused.html MediaRemote will set any app whose audio session category changes from MediaPlayback to Ambient as not eligable for being the "now playing" app. Previously, due to the ordering of events, we never moved from MediaPlayback to Ambient when pausing