diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-10-18 15:46:42 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-10-18 15:46:42 +0100 |
commit | 1e202183a5dc46166763171984b285173f8585e5 (patch) | |
tree | 517398a639c159ddd045ba23c6e1276a21899050 /Source/web | |
parent | 2c9d3f38c113c1e8767ec34552f06c92def51abe (diff) | |
download | WebKit-1e202183a5dc46166763171984b285173f8585e5.tar.gz |
Merge from Chromium at DEPS revision 228962
This commit was generated by merge_to_master.py.
Change-Id: Ifa868e6d63fe87d2338d9388aa5ea81f746d485f
Diffstat (limited to 'Source/web')
228 files changed, 9640 insertions, 5579 deletions
diff --git a/Source/web/.gitignore b/Source/web/.gitignore deleted file mode 100644 index 49b7660b2..000000000 --- a/Source/web/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Generated XCode projects. -web.xcodeproj -web_tests.xcodeproj diff --git a/Source/web/ApplicationCacheHost.cpp b/Source/web/ApplicationCacheHost.cpp index e13e24a9c..964d9bf7a 100644 --- a/Source/web/ApplicationCacheHost.cpp +++ b/Source/web/ApplicationCacheHost.cpp @@ -44,7 +44,7 @@ #include "core/loader/DocumentLoader.h" #include "core/loader/FrameLoader.h" #include "core/loader/appcache/ApplicationCache.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include "core/page/Page.h" #include "core/page/Settings.h" #include "core/platform/chromium/support/WrappedResourceRequest.h" diff --git a/Source/web/AssertMatchingEnums.cpp b/Source/web/AssertMatchingEnums.cpp index d8bc40582..484b02165 100644 --- a/Source/web/AssertMatchingEnums.cpp +++ b/Source/web/AssertMatchingEnums.cpp @@ -39,7 +39,6 @@ #include "WebConsoleMessage.h" #include "WebContentSecurityPolicy.h" #include "WebCursorInfo.h" -#include "WebEditingAction.h" #include "WebFontDescription.h" #include "WebFormElement.h" #include "WebGeolocationError.h" @@ -58,13 +57,14 @@ #include "WebTextAffinity.h" #include "WebTextCheckingResult.h" #include "WebTextCheckingType.h" +#include "WebTextDecorationType.h" #include "WebView.h" +#include "bindings/v8/SerializedScriptValue.h" #include "core/accessibility/AXObjectCache.h" #include "core/accessibility/AccessibilityObject.h" #include "core/dom/DocumentMarker.h" #include "core/dom/ExceptionCode.h" #include "core/dom/IconURL.h" -#include "core/editing/EditorInsertAction.h" #include "core/editing/TextAffinity.h" #include "core/fileapi/FileError.h" #include "core/html/HTMLFormElement.h" @@ -72,13 +72,11 @@ #include "core/html/shadow/TextControlInnerElements.h" #include "core/loader/NavigationPolicy.h" #include "core/loader/appcache/ApplicationCacheHost.h" -#include "core/page/ContentSecurityPolicy.h" +#include "core/frame/ContentSecurityPolicy.h" +#include "core/page/InjectedStyleSheet.h" #include "core/page/PageVisibilityState.h" #include "core/page/Settings.h" -#include "core/page/UserContentTypes.h" -#include "core/page/UserStyleSheetTypes.h" #include "core/platform/Cursor.h" -#include "core/platform/FileMetadata.h" #include "core/platform/graphics/ContentDecryptionModuleSession.h" #include "core/platform/graphics/FontDescription.h" #include "core/platform/graphics/FontSmoothingMode.h" @@ -91,9 +89,7 @@ #include "core/platform/mediastream/RTCPeerConnectionHandlerClient.h" #include "core/platform/network/ResourceLoadPriority.h" #include "core/platform/network/ResourceResponse.h" -#include "core/platform/text/TextChecking.h" #include "core/rendering/CompositingReasons.h" -#include "modules/filesystem/FileSystemType.h" #include "modules/geolocation/GeolocationError.h" #include "modules/geolocation/GeolocationPosition.h" #include "modules/indexeddb/IDBCursor.h" @@ -105,6 +101,10 @@ #include "modules/notifications/NotificationClient.h" #include "modules/quota/StorageQuota.h" #include "modules/speech/SpeechRecognitionError.h" +#include "platform/FileMetadata.h" +#include "platform/FileSystemType.h" +#include "platform/text/TextChecking.h" +#include "platform/text/TextDecoration.h" #include "public/platform/WebClipboard.h" #include "public/platform/WebCompositingReasons.h" #include "public/platform/WebFileError.h" @@ -126,6 +126,7 @@ #include "public/platform/WebURLRequest.h" #include "public/platform/WebURLResponse.h" #include "public/web/WebNavigationPolicy.h" +#include "public/web/WebSerializedScriptValueVersion.h" #include "weborigin/ReferrerPolicy.h" #include "wtf/Assertions.h" #include "wtf/text/StringImpl.h" @@ -363,10 +364,6 @@ COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeGrab, Cursor::Grab); COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeGrabbing, Cursor::Grabbing); COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCustom, Cursor::Custom); -COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionTyped, EditorInsertActionTyped); -COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionPasted, EditorInsertActionPasted); -COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped); - COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyNone, FontDescription::NoFamily); COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyStandard, FontDescription::StandardFamily); COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilySerif, FontDescription::SerifFamily); @@ -504,10 +501,8 @@ COMPILE_ASSERT_MATCHING_ENUM(WebSettings::EditingBehaviorAndroid, EditingAndroid COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityUpstream, UPSTREAM); COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityDownstream, DOWNSTREAM); -COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInAllFrames, InjectInAllFrames); -COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInTopFrameOnly, InjectInTopFrameOnly); -COMPILE_ASSERT_MATCHING_ENUM(WebView::UserStyleInjectInExistingDocuments, InjectInExistingDocuments); -COMPILE_ASSERT_MATCHING_ENUM(WebView::UserStyleInjectInSubsequentDocuments, InjectInSubsequentDocuments); +COMPILE_ASSERT_MATCHING_ENUM(WebView::InjectStyleInAllFrames, InjectStyleInAllFrames); +COMPILE_ASSERT_MATCHING_ENUM(WebView::InjectStyleInTopFrameOnly, InjectStyleInTopFrameOnly); COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionUnknownError, UnknownError); COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionConstraintError, ConstraintError); @@ -563,6 +558,15 @@ COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPositionUnavailable, Geol COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeSpelling, TextCheckingTypeSpelling); COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeGrammar, TextCheckingTypeGrammar); +// TODO(rouslan): Remove these comparisons between text-checking and text-decoration enum values after removing the +// deprecated constructor WebTextCheckingResult(WebTextCheckingType). +COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeSpelling, TextDecorationTypeSpelling); +COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeGrammar, TextDecorationTypeGrammar); + +COMPILE_ASSERT_MATCHING_ENUM(WebTextDecorationTypeSpelling, TextDecorationTypeSpelling); +COMPILE_ASSERT_MATCHING_ENUM(WebTextDecorationTypeGrammar, TextDecorationTypeGrammar); +COMPILE_ASSERT_MATCHING_ENUM(WebTextDecorationTypeInvisibleSpellcheck, TextDecorationTypeInvisibleSpellcheck); + COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorNotSupported, NotSupportedError); COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorInvalidModification, InvalidModificationError); COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorInvalidAccess, InvalidAccessError); @@ -696,3 +700,4 @@ COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForBackground, CompositingR COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForMask, CompositingReasonLayerForMask); COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonOverflowScrollingParent, CompositingReasonOverflowScrollingParent); COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonOutOfFlowClipping, CompositingReasonOutOfFlowClipping); +COMPILE_ASSERT_MATCHING_UINT64(kSerializedScriptValueVersion, SerializedScriptValue::wireFormatVersion); diff --git a/Source/web/AssociatedURLLoader.cpp b/Source/web/AssociatedURLLoader.cpp index a1dfcd559..cf8b820bf 100644 --- a/Source/web/AssociatedURLLoader.cpp +++ b/Source/web/AssociatedURLLoader.cpp @@ -37,12 +37,12 @@ #include "core/fetch/CrossOriginAccessControl.h" #include "core/loader/DocumentThreadableLoader.h" #include "core/loader/DocumentThreadableLoaderClient.h" -#include "core/platform/Timer.h" #include "core/platform/chromium/support/WrappedResourceRequest.h" #include "core/platform/chromium/support/WrappedResourceResponse.h" -#include "core/platform/network/HTTPParsers.h" -#include "core/platform/network/ResourceError.h" #include "core/xml/XMLHttpRequest.h" +#include "platform/Timer.h" +#include "platform/network/HTTPParsers.h" +#include "platform/network/ResourceError.h" #include "public/platform/WebHTTPHeaderVisitor.h" #include "public/platform/WebString.h" #include "public/platform/WebURLError.h" diff --git a/Source/web/AutofillPopupMenuClient.cpp b/Source/web/AutofillPopupMenuClient.cpp index 1963dbbd2..f6efddc0a 100644 --- a/Source/web/AutofillPopupMenuClient.cpp +++ b/Source/web/AutofillPopupMenuClient.cpp @@ -40,8 +40,8 @@ #include "core/css/resolver/StyleResolver.h" #include "core/html/HTMLInputElement.h" #include "core/page/Chrome.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/rendering/RenderTheme.h" #include "public/platform/WebString.h" diff --git a/Source/web/ChromeClientImpl.cpp b/Source/web/ChromeClientImpl.cpp index abd57598f..dce10f4de 100644 --- a/Source/web/ChromeClientImpl.cpp +++ b/Source/web/ChromeClientImpl.cpp @@ -75,8 +75,8 @@ #include "core/html/HTMLInputElement.h" #include "core/loader/DocumentLoader.h" #include "core/loader/FrameLoadRequest.h" -#include "core/page/Console.h" -#include "core/page/FrameView.h" +#include "core/frame/Console.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/PagePopupDriver.h" #include "core/page/Settings.h" @@ -85,15 +85,15 @@ #include "core/platform/ColorChooserClient.h" #include "core/platform/Cursor.h" #include "core/platform/DateTimeChooser.h" -#include "core/platform/FileChooser.h" #include "core/platform/PlatformScreen.h" #include "core/platform/chromium/support/WrappedResourceRequest.h" -#include "core/platform/graphics/FloatRect.h" #include "core/platform/graphics/GraphicsLayer.h" -#include "core/platform/graphics/IntRect.h" #include "core/rendering/HitTestResult.h" #include "core/rendering/RenderWidget.h" #include "modules/geolocation/Geolocation.h" +#include "platform/FileChooser.h" +#include "platform/geometry/FloatRect.h" +#include "platform/geometry/IntRect.h" #include "public/platform/Platform.h" #include "public/platform/WebRect.h" #include "public/platform/WebURLRequest.h" @@ -599,9 +599,9 @@ void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir) tooltipText, textDirection); } -void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const +void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescription& description) const { - m_webView->updatePageDefinedPageScaleConstraints(arguments); + m_webView->updatePageDefinedPageScaleConstraints(description); } void ChromeClientImpl::print(Frame* frame) @@ -715,7 +715,7 @@ void ChromeClientImpl::popupOpened(PopupContainer* popupContainer, // transparent to the WebView. m_webView->popupOpened(popupContainer); } - static_cast<WebPopupMenuImpl*>(webwidget)->initialize(popupContainer, bounds); + toWebPopupMenuImpl(webwidget)->initialize(popupContainer, bounds); } void ChromeClientImpl::popupClosed(WebCore::PopupContainer* popupContainer) @@ -747,9 +747,6 @@ void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor) void ChromeClientImpl::formStateDidChange(const Node* node) { - if (m_webView->client()) - m_webView->client()->didChangeFormState(WebNode(const_cast<Node*>(node))); - // The current history item is not updated yet. That happens lazily when // WebFrame::currentHistoryItem is requested. WebFrameImpl* webframe = WebFrameImpl::fromFrame(node->document().frame()); diff --git a/Source/web/ChromeClientImpl.h b/Source/web/ChromeClientImpl.h index 48ed83680..1307affd7 100644 --- a/Source/web/ChromeClientImpl.h +++ b/Source/web/ChromeClientImpl.h @@ -127,7 +127,7 @@ public: virtual void mouseDidMoveOverElement( const WebCore::HitTestResult& result, unsigned modifierFlags); virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection); - virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const; + virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportDescription&) const; virtual void print(WebCore::Frame*); virtual void annotatedRegionsChanged(); virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&); @@ -188,6 +188,8 @@ public: virtual void didAssociateFormControls(const Vector<RefPtr<WebCore::Element> >&) OVERRIDE; private: + virtual bool isChromeClientImpl() const OVERRIDE { return true; } + WebNavigationPolicy getNavigationPolicy(); void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*); void setCursor(const WebCursorInfo&); @@ -217,6 +219,12 @@ private: }; #endif +inline ChromeClientImpl* toChromeClientImpl(WebCore::ChromeClient& client) +{ + ASSERT_WITH_SECURITY_IMPLICATION(client.isChromeClientImpl()); + return static_cast<ChromeClientImpl*>(&client); +} + } // namespace WebKit #endif diff --git a/Source/web/ColorChooserPopupUIController.cpp b/Source/web/ColorChooserPopupUIController.cpp index 5869a2d05..9d3438257 100644 --- a/Source/web/ColorChooserPopupUIController.cpp +++ b/Source/web/ColorChooserPopupUIController.cpp @@ -31,10 +31,9 @@ #include "PickerCommon.h" #include "WebColorChooser.h" #include "WebViewImpl.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/platform/ColorChooserClient.h" -#include "core/platform/LocalizedStrings.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/geometry/IntRect.h" #include "public/platform/Platform.h" #include "public/platform/WebLocalizedString.h" @@ -54,7 +53,7 @@ ColorChooserPopupUIController::ColorChooserPopupUIController(ChromeClientImpl* c , m_chromeClient(chromeClient) , m_client(client) , m_popup(0) - , m_locale(Locale::createDefault()) + , m_locale(Locale::defaultLocale()) { } diff --git a/Source/web/ColorChooserPopupUIController.h b/Source/web/ColorChooserPopupUIController.h index 18a8fca75..d837be35e 100644 --- a/Source/web/ColorChooserPopupUIController.h +++ b/Source/web/ColorChooserPopupUIController.h @@ -64,7 +64,7 @@ private: ChromeClientImpl* m_chromeClient; WebCore::ColorChooserClient* m_client; WebCore::PagePopup* m_popup; - OwnPtr<WebCore::Locale> m_locale; + WebCore::Locale* m_locale; }; } diff --git a/Source/web/ColorChooserUIController.h b/Source/web/ColorChooserUIController.h index 7b4761cfd..cf21baa36 100644 --- a/Source/web/ColorChooserUIController.h +++ b/Source/web/ColorChooserUIController.h @@ -28,7 +28,7 @@ #include "WebColorChooserClient.h" #include "core/platform/ColorChooser.h" -#include "core/platform/text/PlatformLocale.h" +#include "platform/text/PlatformLocale.h" #include "wtf/OwnPtr.h" namespace WebCore { diff --git a/Source/web/ContextFeaturesClientImpl.cpp b/Source/web/ContextFeaturesClientImpl.cpp index 4fc801b7a..4d1edf4ea 100644 --- a/Source/web/ContextFeaturesClientImpl.cpp +++ b/Source/web/ContextFeaturesClientImpl.cpp @@ -40,7 +40,7 @@ using namespace WebCore; namespace WebKit { -class ContextFeaturesCache : public Supplement<ScriptExecutionContext> { +class ContextFeaturesCache : public DocumentSupplement { public: class Entry { public: @@ -101,10 +101,10 @@ const char* ContextFeaturesCache::supplementName() ContextFeaturesCache* ContextFeaturesCache::from(Document* document) { - ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(Supplement<ScriptExecutionContext>::from(document, supplementName())); + ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(DocumentSupplement::from(document, supplementName())); if (!cache) { cache = new ContextFeaturesCache(); - Supplement<ScriptExecutionContext>::provideTo(document, supplementName(), adoptPtr(cache)); + DocumentSupplement::provideTo(document, supplementName(), adoptPtr(cache)); } return cache; diff --git a/Source/web/ContextMenuClientImpl.cpp b/Source/web/ContextMenuClientImpl.cpp index 040f44d08..42f8b1a2a 100644 --- a/Source/web/ContextMenuClientImpl.cpp +++ b/Source/web/ContextMenuClientImpl.cpp @@ -49,6 +49,7 @@ #include "core/dom/Document.h" #include "core/dom/DocumentMarkerController.h" #include "core/editing/Editor.h" +#include "core/editing/SpellChecker.h" #include "core/history/HistoryItem.h" #include "core/html/HTMLFormElement.h" #include "core/html/HTMLInputElement.h" @@ -60,14 +61,14 @@ #include "core/loader/FrameLoader.h" #include "core/page/ContextMenuController.h" #include "core/page/EventHandler.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/Settings.h" #include "core/platform/ContextMenu.h" -#include "core/platform/Widget.h" -#include "core/platform/text/TextBreakIterator.h" #include "core/rendering/HitTestResult.h" #include "core/rendering/RenderWidget.h" +#include "platform/Widget.h" +#include "platform/text/TextBreakIterator.h" #include "public/platform/WebPoint.h" #include "public/platform/WebString.h" #include "public/platform/WebURL.h" @@ -100,7 +101,7 @@ static WebURL urlFromFrame(Frame* frame) static bool isASingleWord(const String& text) { TextBreakIterator* it = wordBreakIterator(text, 0, text.length()); - return it && textBreakNext(it) == static_cast<int>(text.length()); + return it && it->next() == static_cast<int>(text.length()); } // Helper function to get misspelled word on which context menu @@ -320,9 +321,9 @@ void ContextMenuClientImpl::showContextMenu(const WebCore::ContextMenu* defaultM } } else { data.isSpellCheckingEnabled = - m_webView->focusedWebCoreFrame()->editor().isContinuousSpellCheckingEnabled(); + m_webView->focusedWebCoreFrame()->spellChecker().isContinuousSpellCheckingEnabled(); // Spellchecking might be enabled for the field, but could be disabled on the node. - if (m_webView->focusedWebCoreFrame()->editor().isSpellCheckingEnabledInFocusedNode()) { + if (m_webView->focusedWebCoreFrame()->spellChecker().isSpellCheckingEnabledInFocusedNode()) { data.misspelledWord = selectMisspelledWord(selectedFrame); if (m_webView->spellCheckClient()) { int misspelledOffset, misspelledLength; diff --git a/Source/web/DEPS b/Source/web/DEPS index b1ad93e22..3d813af99 100644 --- a/Source/web/DEPS +++ b/Source/web/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+core", "+modules", "+painting", + "+platform", "+public", "+public/platform", "+skia", diff --git a/Source/web/DatabaseObserver.cpp b/Source/web/DatabaseObserver.cpp index d1d4aa5aa..e1399a46d 100644 --- a/Source/web/DatabaseObserver.cpp +++ b/Source/web/DatabaseObserver.cpp @@ -44,7 +44,7 @@ #include "bindings/v8/WorkerScriptController.h" #include "core/dom/CrossThreadTask.h" #include "core/dom/Document.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/platform/CrossThreadCopier.h" #include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerLoaderProxy.h" @@ -128,12 +128,12 @@ bool allowDatabaseForWorker(WebFrame* frame, const WebString& name, const WebStr namespace WebCore { -bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize) +bool DatabaseObserver::canEstablishDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize) { - ASSERT(scriptExecutionContext->isContextThread()); - ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerGlobalScope()); - if (scriptExecutionContext->isDocument()) { - Document* document = toDocument(scriptExecutionContext); + ASSERT(executionContext->isContextThread()); + ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalScope()); + if (executionContext->isDocument()) { + Document* document = toDocument(executionContext); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); if (!webFrame) return false; @@ -143,7 +143,7 @@ bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecut if (webView->permissionClient()) return webView->permissionClient()->allowDatabase(webFrame, name, displayName, estimatedSize); } else { - WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(scriptExecutionContext); + WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionContext); WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase()); WebView* view = webWorker->view(); if (!view) @@ -156,19 +156,19 @@ bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecut void DatabaseObserver::databaseOpened(DatabaseBackendBase* database) { - ASSERT(database->databaseContext()->scriptExecutionContext()->isContextThread()); + ASSERT(database->databaseContext()->executionContext()->isContextThread()); WebDatabase::observer()->databaseOpened(WebDatabase(database)); } void DatabaseObserver::databaseModified(DatabaseBackendBase* database) { - ASSERT(database->databaseContext()->scriptExecutionContext()->isContextThread()); + ASSERT(database->databaseContext()->executionContext()->isContextThread()); WebDatabase::observer()->databaseModified(WebDatabase(database)); } void DatabaseObserver::databaseClosed(DatabaseBackendBase* database) { - ASSERT(database->databaseContext()->scriptExecutionContext()->isContextThread()); + ASSERT(database->databaseContext()->executionContext()->isContextThread()); WebDatabase::observer()->databaseClosed(WebDatabase(database)); } diff --git a/Source/web/DateTimeChooserImpl.cpp b/Source/web/DateTimeChooserImpl.cpp index b1beeba73..4cb480129 100644 --- a/Source/web/DateTimeChooserImpl.cpp +++ b/Source/web/DateTimeChooserImpl.cpp @@ -37,13 +37,13 @@ #include "PickerCommon.h" #include "WebViewImpl.h" #include "core/html/forms/InputTypeNames.h" -#include "core/page/FrameView.h" -#include "core/platform/DateComponents.h" +#include "core/frame/FrameView.h" #include "core/platform/DateTimeChooserClient.h" -#include "core/platform/Language.h" -#include "core/platform/NotImplemented.h" -#include "core/platform/text/PlatformLocale.h" #include "core/rendering/RenderTheme.h" +#include "platform/DateComponents.h" +#include "platform/Language.h" +#include "platform/NotImplemented.h" +#include "platform/text/PlatformLocale.h" #include "public/platform/Platform.h" #include "public/platform/WebLocalizedString.h" @@ -119,11 +119,10 @@ void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer) } addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer); - writer.addData(WebCore::pickerCommonCss, sizeof(WebCore::pickerCommonCss)); - writer.addData(WebCore::pickerCommonChromiumCss, sizeof(WebCore::pickerCommonChromiumCss)); - writer.addData(WebCore::suggestionPickerCss, sizeof(WebCore::suggestionPickerCss)); - writer.addData(WebCore::calendarPickerCss, sizeof(WebCore::calendarPickerCss)); - writer.addData(WebCore::calendarPickerChromiumCss, sizeof(WebCore::calendarPickerChromiumCss)); + writer.addData(pickerCommonCss, sizeof(pickerCommonCss)); + writer.addData(pickerButtonCss, sizeof(pickerButtonCss)); + writer.addData(suggestionPickerCss, sizeof(suggestionPickerCss)); + writer.addData(calendarPickerCss, sizeof(calendarPickerCss)); addString("</style></head><body><div id=main>Loading...</div><script>\n" "window.dialogArguments = {\n", writer); addProperty("anchorRectInScreen", anchorRectInScreen, writer); @@ -155,9 +154,9 @@ void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer) } addString("}\n", writer); - writer.addData(WebCore::pickerCommonJs, sizeof(WebCore::pickerCommonJs)); - writer.addData(WebCore::suggestionPickerJs, sizeof(WebCore::suggestionPickerJs)); - writer.addData(WebCore::calendarPickerJs, sizeof(WebCore::calendarPickerJs)); + writer.addData(pickerCommonJs, sizeof(pickerCommonJs)); + writer.addData(suggestionPickerJs, sizeof(suggestionPickerJs)); + writer.addData(calendarPickerJs, sizeof(calendarPickerJs)); addString("</script></body>\n", writer); } diff --git a/Source/web/DeviceOrientationClientProxy.cpp b/Source/web/DeviceOrientationClientProxy.cpp deleted file mode 100644 index 8afee3416..000000000 --- a/Source/web/DeviceOrientationClientProxy.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "DeviceOrientationClientProxy.h" - -#include "WebDeviceOrientation.h" -#include "WebDeviceOrientationController.h" -#include "wtf/OwnPtr.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefPtr.h" - -namespace WebCore { -class DeviceOrientationController; -} - -namespace WebKit { - -void DeviceOrientationClientProxy::setController(WebCore::DeviceOrientationController* c) -{ - if (!m_client) // FIXME: Get rid of these null checks once device orientation is enabled by default. - return; - m_client->setController(new WebDeviceOrientationController(c)); -} - -void DeviceOrientationClientProxy::startUpdating() -{ - if (!m_client) - return; - m_client->startUpdating(); -} - -void DeviceOrientationClientProxy::stopUpdating() -{ - if (!m_client) - return; - m_client->stopUpdating(); -} - -WebCore::DeviceOrientationData* DeviceOrientationClientProxy::lastOrientation() const -{ - if (!m_client) - return 0; - - // Cache the DeviceOrientationData pointer so its reference count does not drop to zero upon return. - m_lastOrientation = m_client->lastOrientation(); - - return m_lastOrientation.get(); -} - -void DeviceOrientationClientProxy::deviceOrientationControllerDestroyed() -{ - // Our lifetime is bound to the WebViewImpl. -} - -} // namespace WebKit diff --git a/Source/web/DeviceOrientationClientProxy.h b/Source/web/DeviceOrientationClientProxy.h deleted file mode 100644 index f54caae15..000000000 --- a/Source/web/DeviceOrientationClientProxy.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef DeviceOrientationClientProxy_h -#define DeviceOrientationClientProxy_h - -#include "WebDeviceOrientationClient.h" -#include "core/dom/DeviceOrientationClient.h" -#include "modules/device_orientation/DeviceOrientationData.h" -#include "wtf/RefPtr.h" - -namespace WebCore { -class DeviceOrientationController; -} - -namespace WebKit { - -class DeviceOrientationClientProxy : public WebCore::DeviceOrientationClient { -public: - DeviceOrientationClientProxy(WebDeviceOrientationClient* client) - : m_client(client) - { - } - - virtual void setController(WebCore::DeviceOrientationController*) OVERRIDE; - virtual void startUpdating() OVERRIDE; - virtual void stopUpdating() OVERRIDE; - virtual WebCore::DeviceOrientationData* lastOrientation() const OVERRIDE; - virtual void deviceOrientationControllerDestroyed() OVERRIDE; - -private: - WebDeviceOrientationClient* m_client; - mutable RefPtr<WebCore::DeviceOrientationData> m_lastOrientation; -}; - -} // namespace WebKit - -#endif // DeviceOrientationClientProxy_h diff --git a/Source/web/DragClientImpl.cpp b/Source/web/DragClientImpl.cpp index 9cf856b97..7597adc56 100644 --- a/Source/web/DragClientImpl.cpp +++ b/Source/web/DragClientImpl.cpp @@ -32,12 +32,12 @@ #include "DragClientImpl.h" #include "WebViewClient.h" #include "WebViewImpl.h" -#include "core/page/Frame.h" +#include "core/dom/Clipboard.h" +#include "core/frame/Frame.h" #include "core/platform/DragImage.h" #include "core/platform/chromium/ChromiumDataObject.h" -#include "core/platform/chromium/ClipboardChromium.h" -#include "core/platform/graphics/IntSize.h" #include "core/platform/graphics/skia/NativeImageSkia.h" +#include "platform/geometry/IntSize.h" #include "public/platform/WebCommon.h" #include "public/platform/WebDragData.h" #include "public/platform/WebImage.h" @@ -69,7 +69,7 @@ void DragClientImpl::startDrag(DragImage* dragImage, // Add a ref to the frame just in case a load occurs mid-drag. RefPtr<Frame> frameProtector = frame; - WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject(); + WebDragData dragData = clipboard->dataObject(); WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation()); WebImage image; IntSize offsetSize(eventPos - dragImageOrigin); diff --git a/Source/web/EditorClientImpl.cpp b/Source/web/EditorClientImpl.cpp index 1716277da..7f2f1174d 100644 --- a/Source/web/EditorClientImpl.cpp +++ b/Source/web/EditorClientImpl.cpp @@ -29,7 +29,6 @@ #include "HTMLNames.h" #include "WebAutofillClient.h" -#include "WebEditingAction.h" #include "WebElement.h" #include "WebFrameClient.h" #include "WebFrameImpl.h" @@ -47,21 +46,21 @@ #include "WebViewImpl.h" #include "core/dom/Document.h" #include "core/dom/DocumentMarkerController.h" -#include "core/events/EventNames.h" -#include "core/events/KeyboardEvent.h" #include "core/editing/Editor.h" -#include "core/editing/SpellCheckRequester.h" +#include "core/editing/SpellChecker.h" #include "core/editing/TextCheckingHelper.h" #include "core/editing/UndoStep.h" +#include "core/events/KeyboardEvent.h" +#include "core/events/ThreadLocalEventNames.h" #include "core/html/HTMLInputElement.h" #include "core/page/EventHandler.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include "core/page/Page.h" #include "core/page/Settings.h" -#include "core/platform/NotImplemented.h" -#include "core/platform/PlatformKeyboardEvent.h" #include "core/platform/chromium/KeyboardCodes.h" #include "core/rendering/RenderObject.h" +#include "platform/NotImplemented.h" +#include "platform/PlatformKeyboardEvent.h" #include "wtf/text/WTFString.h" using namespace WebCore; @@ -106,8 +105,7 @@ bool EditorClientImpl::shouldSpellcheckByDefault() const Frame* frame = m_webView->focusedWebCoreFrame(); if (!frame) return false; - const Editor& editor = frame->editor(); - if (editor.isSpellCheckingEnabledInFocusedNode()) + if (frame->spellChecker().isSpellCheckingEnabledInFocusedNode()) return true; const Document* document = frame->document(); if (!document) @@ -152,7 +150,7 @@ void EditorClientImpl::toggleContinuousSpellChecking() VisibleSelection frameSelection = frame->selection().selection(); // If a selection is in an editable element spell check its content. if (Element* rootEditableElement = frameSelection.rootEditableElement()) { - frame->editor().elementDidBeginEditing(rootEditableElement); + frame->editor().didBeginEditing(rootEditableElement); } } } @@ -164,81 +162,6 @@ bool EditorClientImpl::isGrammarCheckingEnabled() return frame && frame->settings() && (frame->settings()->asynchronousSpellCheckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); } -bool EditorClientImpl::shouldBeginEditing(Range* range) -{ - if (m_webView->client()) - return m_webView->client()->shouldBeginEditing(WebRange(range)); - return true; -} - -bool EditorClientImpl::shouldEndEditing(Range* range) -{ - if (m_webView->client()) - return m_webView->client()->shouldEndEditing(WebRange(range)); - return true; -} - -bool EditorClientImpl::shouldInsertNode(Node* node, - Range* range, - EditorInsertAction action) -{ - if (m_webView->client()) { - return m_webView->client()->shouldInsertNode(WebNode(node), - WebRange(range), - static_cast<WebEditingAction>(action)); - } - return true; -} - -bool EditorClientImpl::shouldInsertText(const String& text, - Range* range, - EditorInsertAction action) -{ - if (m_webView->client()) { - return m_webView->client()->shouldInsertText(WebString(text), - WebRange(range), - static_cast<WebEditingAction>(action)); - } - return true; -} - - -bool EditorClientImpl::shouldDeleteRange(Range* range) -{ - if (m_webView->client()) - return m_webView->client()->shouldDeleteRange(WebRange(range)); - return true; -} - -bool EditorClientImpl::shouldChangeSelectedRange(Range* fromRange, - Range* toRange, - EAffinity affinity, - bool stillSelecting) -{ - if (m_webView->client()) { - return m_webView->client()->shouldChangeSelectedRange(WebRange(fromRange), - WebRange(toRange), - static_cast<WebTextAffinity>(affinity), - stillSelecting); - } - return true; -} - -bool EditorClientImpl::shouldApplyStyle(StylePropertySet* style, Range* range) -{ - if (m_webView->client()) { - // FIXME: Pass a reference to the CSSStyleDeclaration somehow. - return m_webView->client()->shouldApplyStyle(WebString(), WebRange(range)); - } - return true; -} - -void EditorClientImpl::didBeginEditing() -{ - if (m_webView->client()) - m_webView->client()->didBeginEditing(); -} - void EditorClientImpl::respondToChangedSelection(Frame* frame) { if (m_webView->client() && frame) @@ -251,12 +174,6 @@ void EditorClientImpl::respondToChangedContents() m_webView->client()->didChangeContents(); } -void EditorClientImpl::didEndEditing() -{ - if (m_webView->client()) - m_webView->client()->didEndEditing(); -} - void EditorClientImpl::didCancelCompositionOnSelectionChange() { if (m_webView->client()) @@ -733,7 +650,7 @@ void EditorClientImpl::checkGrammarOfString(const String& text, WTF::Vector<Gram // badGrammarLocation and badGrammarLength to tell WebKit that the input // text has grammar errors. for (size_t i = 0; i < webResults.size(); ++i) { - if (webResults[i].type == WebTextCheckingTypeGrammar) { + if (webResults[i].decoration == WebTextDecorationTypeGrammar) { GrammarDetail detail; detail.location = webResults[i].location; detail.length = webResults[i].length; diff --git a/Source/web/EditorClientImpl.h b/Source/web/EditorClientImpl.h index b140f44c6..8f76d8115 100644 --- a/Source/web/EditorClientImpl.h +++ b/Source/web/EditorClientImpl.h @@ -32,8 +32,8 @@ #define EditorClientImpl_h #include "core/page/EditorClient.h" -#include "core/platform/Timer.h" -#include "core/platform/text/TextCheckerClient.h" +#include "platform/Timer.h" +#include "platform/text/TextCheckerClient.h" #include "wtf/Deque.h" #include "wtf/HashSet.h" @@ -57,18 +57,8 @@ public: virtual bool isContinuousSpellCheckingEnabled() OVERRIDE; virtual void toggleContinuousSpellChecking() OVERRIDE; virtual bool isGrammarCheckingEnabled() OVERRIDE; - virtual bool shouldBeginEditing(WebCore::Range*) OVERRIDE; - virtual bool shouldEndEditing(WebCore::Range*) OVERRIDE; - virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) OVERRIDE; - virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction) OVERRIDE; - virtual bool shouldDeleteRange(WebCore::Range*) OVERRIDE; - virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, - WebCore::EAffinity, bool stillSelecting) OVERRIDE; - virtual bool shouldApplyStyle(WebCore::StylePropertySet*, WebCore::Range*) OVERRIDE; - virtual void didBeginEditing() OVERRIDE; virtual void respondToChangedContents() OVERRIDE; virtual void respondToChangedSelection(WebCore::Frame*) OVERRIDE; - virtual void didEndEditing() OVERRIDE; virtual void didCancelCompositionOnSelectionChange() OVERRIDE; virtual void registerUndoStep(PassRefPtr<WebCore::UndoStep>) OVERRIDE; virtual void registerRedoStep(PassRefPtr<WebCore::UndoStep>) OVERRIDE; diff --git a/Source/web/EventListenerWrapper.cpp b/Source/web/EventListenerWrapper.cpp index 6c1eccc08..b1216143a 100644 --- a/Source/web/EventListenerWrapper.cpp +++ b/Source/web/EventListenerWrapper.cpp @@ -58,7 +58,7 @@ bool EventListenerWrapper::operator==(const EventListener& listener) return this == &listener; } -void EventListenerWrapper::handleEvent(ScriptExecutionContext* context, Event* event) +void EventListenerWrapper::handleEvent(ExecutionContext* context, Event* event) { if (!m_webDOMEventListener) return; diff --git a/Source/web/EventListenerWrapper.h b/Source/web/EventListenerWrapper.h index af96812b7..4ac82fda6 100644 --- a/Source/web/EventListenerWrapper.h +++ b/Source/web/EventListenerWrapper.h @@ -34,7 +34,7 @@ #include "core/events/EventListener.h" namespace WebCore { -class ScriptExecutionContext; +class ExecutionContext; } namespace WebKit { @@ -49,7 +49,7 @@ public: ~EventListenerWrapper(); virtual bool operator==(const WebCore::EventListener&); - virtual void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*); + virtual void handleEvent(WebCore::ExecutionContext*, WebCore::Event*); void webDOMEventListenerDeleted(); diff --git a/Source/web/ExternalPopupMenu.cpp b/Source/web/ExternalPopupMenu.cpp index f2c38a96a..5ae673657 100644 --- a/Source/web/ExternalPopupMenu.cpp +++ b/Source/web/ExternalPopupMenu.cpp @@ -35,12 +35,12 @@ #include "WebMenuItemInfo.h" #include "WebPopupMenuInfo.h" #include "WebViewClient.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/platform/PopupMenuClient.h" -#include "core/platform/graphics/FloatQuad.h" -#include "core/platform/graphics/IntPoint.h" -#include "core/platform/text/TextDirection.h" +#include "platform/geometry/FloatQuad.h" +#include "platform/geometry/IntPoint.h" +#include "platform/text/TextDirection.h" #include "public/platform/WebVector.h" using namespace WebCore; diff --git a/Source/web/FindInPageCoordinates.cpp b/Source/web/FindInPageCoordinates.cpp index 125e83efe..6019a7957 100644 --- a/Source/web/FindInPageCoordinates.cpp +++ b/Source/web/FindInPageCoordinates.cpp @@ -33,17 +33,17 @@ #include "core/dom/Node.h" #include "core/dom/Range.h" -#include "core/page/Frame.h" -#include "core/platform/graphics/FloatPoint.h" -#include "core/platform/graphics/FloatQuad.h" -#include "core/platform/graphics/FloatRect.h" -#include "core/platform/graphics/IntPoint.h" +#include "core/frame/Frame.h" #include "core/rendering/RenderBlock.h" #include "core/rendering/RenderBox.h" #include "core/rendering/RenderObject.h" #include "core/rendering/RenderPart.h" #include "core/rendering/RenderView.h" #include "core/rendering/style/RenderStyle.h" +#include "platform/geometry/FloatPoint.h" +#include "platform/geometry/FloatQuad.h" +#include "platform/geometry/FloatRect.h" +#include "platform/geometry/IntPoint.h" using namespace WebCore; diff --git a/Source/web/FindInPageCoordinates.h b/Source/web/FindInPageCoordinates.h index 7c12e8cb1..de1ba9199 100644 --- a/Source/web/FindInPageCoordinates.h +++ b/Source/web/FindInPageCoordinates.h @@ -31,7 +31,7 @@ #ifndef FindInPageCoordinates_h #define FindInPageCoordinates_h -#include "core/platform/graphics/FloatRect.h" +#include "platform/geometry/FloatRect.h" namespace WebCore { class Range; diff --git a/Source/web/FrameLoaderClientImpl.cpp b/Source/web/FrameLoaderClientImpl.cpp index d8391f837..f443d71e6 100644 --- a/Source/web/FrameLoaderClientImpl.cpp +++ b/Source/web/FrameLoaderClientImpl.cpp @@ -56,8 +56,6 @@ #include "core/dom/Document.h" #include "core/events/MessageEvent.h" #include "core/events/MouseEvent.h" -#include "core/dom/TouchController.h" -#include "core/dom/UserGestureIndicator.h" #include "core/dom/WheelController.h" #include "core/history/HistoryItem.h" #include "core/html/HTMLAppletElement.h" @@ -69,7 +67,7 @@ #include "core/loader/ProgressTracker.h" #include "core/page/Chrome.h" #include "core/page/EventHandler.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/Settings.h" #include "core/page/WindowFeatures.h" @@ -77,13 +75,16 @@ #include "core/platform/chromium/support/WrappedResourceRequest.h" #include "core/platform/chromium/support/WrappedResourceResponse.h" #include "core/platform/mediastream/RTCPeerConnectionHandler.h" -#include "core/platform/network/HTTPParsers.h" -#include "core/platform/network/SocketStreamHandleInternal.h" #include "core/plugins/PluginData.h" #include "core/rendering/HitTestResult.h" #include "modules/device_orientation/DeviceMotionController.h" +#include "platform/UserGestureIndicator.h" +#include "platform/network/HTTPParsers.h" +#include "platform/network/SocketStreamHandleInternal.h" #include "public/platform/Platform.h" #include "public/platform/WebMimeRegistry.h" +#include "public/platform/WebServiceWorkerProvider.h" +#include "public/platform/WebServiceWorkerProviderClient.h" #include "public/platform/WebSocketStreamHandle.h" #include "public/platform/WebURL.h" #include "public/platform/WebURLError.h" @@ -123,7 +124,6 @@ void FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* m_webFrame->client()->didClearWindowObject(m_webFrame); Document* document = m_webFrame->frame()->document(); if (document) { - TouchController::from(document); WheelController::from(document); if (RuntimeEnabledFeatures::deviceMotionEnabled()) DeviceMotionController::from(document); @@ -424,14 +424,9 @@ void FrameLoaderClientImpl::dispatchDidFinishLoad() // provisional load succeeds or fails, not the "real" one. } -void FrameLoaderClientImpl::dispatchDidLayout(LayoutMilestones milestones) +void FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout() { - if (!m_webFrame->client()) - return; - - if (milestones & DidFirstLayout) - m_webFrame->client()->didFirstLayout(m_webFrame); - if (milestones & DidFirstVisuallyNonEmptyLayout) + if (m_webFrame->client()) m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame); } @@ -541,6 +536,12 @@ void FrameLoaderClientImpl::didDispatchPingLoader(const KURL& url) m_webFrame->client()->didDispatchPingLoader(m_webFrame, url); } +void FrameLoaderClientImpl::selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors) +{ + if (WebFrameClient* client = m_webFrame->client()) + client->didMatchCSS(m_webFrame, WebVector<WebString>(addedSelectors), WebVector<WebString>(removedSelectors)); +} + PassRefPtr<DocumentLoader> FrameLoaderClientImpl::createDocumentLoader( const ResourceRequest& request, const SubstituteData& data) @@ -753,11 +754,11 @@ void FrameLoaderClientImpl::dispatchWillInsertBody() m_webFrame->client()->willInsertBody(m_webFrame); } -WebServiceWorkerRegistry* FrameLoaderClientImpl::serviceWorkerRegistry() +PassOwnPtr<WebServiceWorkerProvider> FrameLoaderClientImpl::createServiceWorkerProvider(PassOwnPtr<WebServiceWorkerProviderClient> client) { if (!m_webFrame->client()) - return 0; - return m_webFrame->client()->serviceWorkerRegistry(m_webFrame); + return nullptr; + return adoptPtr(m_webFrame->client()->createServiceWorkerProvider(m_webFrame, client.leakPtr())); } void FrameLoaderClientImpl::didStopAllLoaders() diff --git a/Source/web/FrameLoaderClientImpl.h b/Source/web/FrameLoaderClientImpl.h index c8b9ed4fe..cb19cb408 100644 --- a/Source/web/FrameLoaderClientImpl.h +++ b/Source/web/FrameLoaderClientImpl.h @@ -91,7 +91,7 @@ public: virtual void dispatchDidFailLoad(const WebCore::ResourceError&); virtual void dispatchDidFinishDocumentLoad(); virtual void dispatchDidFinishLoad(); - virtual void dispatchDidLayout(WebCore::LayoutMilestones); + virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE; virtual WebCore::NavigationPolicy decidePolicyForNavigation(const WebCore::ResourceRequest&, WebCore::DocumentLoader*, WebCore::NavigationPolicy); virtual void dispatchWillRequestResource(WebCore::FetchRequest*); virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>); @@ -107,6 +107,7 @@ public: virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL& insecureURL); virtual void didDetectXSS(const WebCore::KURL&, bool didBlockEntirePage); virtual void didDispatchPingLoader(const WebCore::KURL&); + virtual void selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors); virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader( const WebCore::ResourceRequest&, const WebCore::SubstituteData&); virtual WTF::String userAgent(const WebCore::KURL&); @@ -150,11 +151,13 @@ public: virtual void dispatchWillInsertBody() OVERRIDE; - virtual WebServiceWorkerRegistry* serviceWorkerRegistry() OVERRIDE; + virtual PassOwnPtr<WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<WebServiceWorkerProviderClient>) OVERRIDE; virtual void didStopAllLoaders() OVERRIDE; private: + virtual bool isFrameLoaderClientImpl() const OVERRIDE { return true; } + PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver(); // The WebFrame that owns this object and manages its lifetime. Therefore, @@ -162,6 +165,12 @@ private: WebFrameImpl* m_webFrame; }; +inline FrameLoaderClientImpl* toFrameLoaderClientImpl(WebCore::FrameLoaderClient* client) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!client || client->isFrameLoaderClientImpl()); + return static_cast<FrameLoaderClientImpl*>(client); +} + } // namespace WebKit #endif diff --git a/Source/web/FullscreenController.cpp b/Source/web/FullscreenController.cpp index f8d132644..bfc561bf7 100644 --- a/Source/web/FullscreenController.cpp +++ b/Source/web/FullscreenController.cpp @@ -38,8 +38,8 @@ #include "core/dom/Document.h" #include "core/dom/FullscreenElementStack.h" #include "core/html/HTMLMediaElement.h" -#include "core/page/Frame.h" -#include "core/platform/LayoutTestSupport.h" +#include "core/frame/Frame.h" +#include "platform/LayoutTestSupport.h" using namespace WebCore; diff --git a/Source/web/FullscreenController.h b/Source/web/FullscreenController.h index c0d3edc59..08a56d140 100644 --- a/Source/web/FullscreenController.h +++ b/Source/web/FullscreenController.h @@ -31,7 +31,7 @@ #ifndef FullscreenController_h #define FullscreenController_h -#include "core/platform/graphics/IntSize.h" +#include "platform/geometry/IntSize.h" #include "wtf/PassOwnPtr.h" #include "wtf/RefPtr.h" diff --git a/Source/web/IDBFactoryBackendProxy.cpp b/Source/web/IDBFactoryBackendProxy.cpp index f665616b9..f0eb7f60a 100644 --- a/Source/web/IDBFactoryBackendProxy.cpp +++ b/Source/web/IDBFactoryBackendProxy.cpp @@ -48,7 +48,7 @@ #include "core/dom/CrossThreadTask.h" #include "core/dom/DOMError.h" #include "core/dom/ExceptionCode.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerLoaderProxy.h" #include "core/workers/WorkerThread.h" @@ -109,7 +109,7 @@ private: } }; -bool IDBFactoryBackendProxy::allowIndexedDB(ScriptExecutionContext* context, const String& name, const WebSecurityOrigin& origin, PassRefPtr<IDBCallbacks> callbacks) +bool IDBFactoryBackendProxy::allowIndexedDB(ExecutionContext* context, const String& name, const WebSecurityOrigin& origin, PassRefPtr<IDBCallbacks> callbacks) { bool allowed; ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument() || context->isWorkerGlobalScope()); @@ -142,7 +142,7 @@ bool IDBFactoryBackendProxy::allowIndexedDB(ScriptExecutionContext* context, con return allowed; } -void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBCallbacks> prpCallbacks, const String& databaseIdentifier, ScriptExecutionContext* context) +void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBCallbacks> prpCallbacks, const String& databaseIdentifier, ExecutionContext* context) { RefPtr<IDBCallbacks> callbacks(prpCallbacks); WebSecurityOrigin origin(context->securityOrigin()); @@ -152,7 +152,7 @@ void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBCallbacks> prpCallba m_webIDBFactory->getDatabaseNames(new WebIDBCallbacksImpl(callbacks), databaseIdentifier); } -void IDBFactoryBackendProxy::open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, const String& databaseIdentifier, ScriptExecutionContext* context) +void IDBFactoryBackendProxy::open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, const String& databaseIdentifier, ExecutionContext* context) { RefPtr<IDBCallbacks> callbacks(prpCallbacks); RefPtr<IDBDatabaseCallbacks> databaseCallbacks(prpDatabaseCallbacks); @@ -163,7 +163,7 @@ void IDBFactoryBackendProxy::open(const String& name, int64_t version, int64_t t m_webIDBFactory->open(name, version, transactionId, new WebIDBCallbacksImpl(callbacks), new WebIDBDatabaseCallbacksImpl(databaseCallbacks), databaseIdentifier); } -void IDBFactoryBackendProxy::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, const String& databaseIdentifier, ScriptExecutionContext* context) +void IDBFactoryBackendProxy::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, const String& databaseIdentifier, ExecutionContext* context) { RefPtr<IDBCallbacks> callbacks(prpCallbacks); WebSecurityOrigin origin(context->securityOrigin()); diff --git a/Source/web/IDBFactoryBackendProxy.h b/Source/web/IDBFactoryBackendProxy.h index 2c9eb602e..c4529dd1c 100644 --- a/Source/web/IDBFactoryBackendProxy.h +++ b/Source/web/IDBFactoryBackendProxy.h @@ -33,7 +33,7 @@ #include "modules/indexeddb/IDBCallbacks.h" namespace WebCore { -class ScriptExecutionContext; +class ExecutionContext; } namespace WebKit { @@ -46,13 +46,13 @@ public: static PassRefPtr<WebCore::IDBFactoryBackendInterface> create(); virtual ~IDBFactoryBackendProxy(); - virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, const String& databaseIdentifier, WebCore::ScriptExecutionContext*) OVERRIDE; - virtual void open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const String& databaseIdentifier, WebCore::ScriptExecutionContext*) OVERRIDE; - virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, const String& databaseIdentifier, WebCore::ScriptExecutionContext*) OVERRIDE; + virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, const String& databaseIdentifier, WebCore::ExecutionContext*) OVERRIDE; + virtual void open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const String& databaseIdentifier, WebCore::ExecutionContext*) OVERRIDE; + virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, const String& databaseIdentifier, WebCore::ExecutionContext*) OVERRIDE; private: IDBFactoryBackendProxy(); - bool allowIndexedDB(WebCore::ScriptExecutionContext*, const String& name, const WebSecurityOrigin&, PassRefPtr<WebCore::IDBCallbacks>); + bool allowIndexedDB(WebCore::ExecutionContext*, const String& name, const WebSecurityOrigin&, PassRefPtr<WebCore::IDBCallbacks>); // We don't own this pointer (unlike all the other proxy classes which do). WebIDBFactory* m_webIDBFactory; diff --git a/Source/web/InspectorClientImpl.cpp b/Source/web/InspectorClientImpl.cpp index dc2421874..51e86af2f 100644 --- a/Source/web/InspectorClientImpl.cpp +++ b/Source/web/InspectorClientImpl.cpp @@ -35,11 +35,11 @@ #include "WebViewClient.h" #include "WebViewImpl.h" #include "core/inspector/InspectorInstrumentation.h" -#include "core/page/DOMWindow.h" +#include "core/frame/DOMWindow.h" #include "core/page/Page.h" #include "core/page/Settings.h" -#include "core/platform/NotImplemented.h" -#include "core/platform/graphics/FloatRect.h" +#include "platform/NotImplemented.h" +#include "platform/geometry/FloatRect.h" #include "public/platform/WebRect.h" #include "public/platform/WebURL.h" #include "public/platform/WebURLRequest.h" @@ -96,16 +96,10 @@ void InspectorClientImpl::clearBrowserCookies() agent->clearBrowserCookies(); } -void InspectorClientImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow) +void InspectorClientImpl::overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool fitWindow) { if (WebDevToolsAgentImpl* agent = devToolsAgent()) - agent->overrideDeviceMetrics(width, height, fontScaleFactor, fitWindow); -} - -void InspectorClientImpl::autoZoomPageToFitWidth() -{ - if (WebDevToolsAgentImpl* agent = devToolsAgent()) - agent->autoZoomPageToFitWidth(); + agent->overrideDeviceMetrics(width, height, deviceScaleFactor, fitWindow); } bool InspectorClientImpl::overridesShowPaintRects() diff --git a/Source/web/InspectorClientImpl.h b/Source/web/InspectorClientImpl.h index 692d64237..0c19bc837 100644 --- a/Source/web/InspectorClientImpl.h +++ b/Source/web/InspectorClientImpl.h @@ -60,7 +60,6 @@ public: virtual void clearBrowserCookies(); virtual void overrideDeviceMetrics(int, int, float, bool); - virtual void autoZoomPageToFitWidth(); virtual bool overridesShowPaintRects(); virtual void setShowPaintRects(bool); diff --git a/Source/web/InspectorFrontendClientImpl.cpp b/Source/web/InspectorFrontendClientImpl.cpp index eab9ff6a8..a4e7807bf 100644 --- a/Source/web/InspectorFrontendClientImpl.cpp +++ b/Source/web/InspectorFrontendClientImpl.cpp @@ -37,9 +37,9 @@ #include "bindings/v8/ScriptController.h" #include "core/dom/Document.h" #include "core/inspector/InspectorFrontendHost.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include "core/page/Page.h" -#include "core/platform/NotImplemented.h" +#include "platform/NotImplemented.h" #include "public/platform/WebFloatPoint.h" #include "public/platform/WebString.h" #include "wtf/text/WTFString.h" @@ -78,32 +78,42 @@ void InspectorFrontendClientImpl::windowObjectCleared() ScriptController* scriptController = m_frontendPage->mainFrame() ? m_frontendPage->mainFrame()->script() : 0; if (scriptController) { String installLegacyOverrides = - "(function(host, legacyMethodNames) {" - " function dispatch(methodName) {" + "" // Support for legacy front-ends (<M31). Do not add items here. + "(function(host, methodNames) {" + " var callId = 0;" + " function dispatch(methodName)" + " {" " var argsArray = Array.prototype.slice.call(arguments, 1);" - " var message = {'method': methodName};" + " var message = {\"method\": methodName, \"id\": ++callId};" " if (argsArray.length)" " message.params = argsArray;" " this.sendMessageToEmbedder(JSON.stringify(message));" " };" - " legacyMethodNames.forEach(function(methodName) {" - " host[methodName] = dispatch.bind(host, methodName);" - " });" + " methodNames.forEach(function(methodName) { host[methodName] = dispatch.bind(host, methodName); });" "})(InspectorFrontendHost," - " ['moveWindowBy'," + " ['addFileSystem'," + " 'append'," " 'bringToFront'," - " 'requestSetDockSide'," + " 'indexPath'," + " 'moveWindowBy'," " 'openInNewTab'," - " 'save'," - " 'append'," + " 'removeFileSystem'," " 'requestFileSystems'," - " 'indexPath'," - " 'stopIndexing'," + " 'requestSetDockSide'," + " 'save'," " 'searchInPath'," - " 'addFileSystem'," - " 'removeFileSystem']);"; - - scriptController->executeScriptInMainWorld(ScriptSourceCode(installLegacyOverrides)); + " 'stopIndexing']);" + "" + "" // Support for legacy front-ends (<M28). Do not add items here. + "InspectorFrontendHost.canInspectWorkers = function() { return true; };" + "InspectorFrontendHost.canSaveAs = function() { return true; };" + "InspectorFrontendHost.canSave = function() { return true; };" + "InspectorFrontendHost.supportsFileSystems = function() { return true; };" + "InspectorFrontendHost.loaded = function() {};" + "InspectorFrontendHost.hiddenPanels = function() { return ""; };" + "InspectorFrontendHost.localizedStringsURL = function() { return ""; };" + "InspectorFrontendHost.close = function(url) { };"; + scriptController->executeScriptInMainWorld(installLegacyOverrides, ScriptController::ExecuteScriptWhenScriptsDisabled); } } diff --git a/Source/web/LinkHighlight.cpp b/Source/web/LinkHighlight.cpp index 0e5347bc3..ec48689d7 100644 --- a/Source/web/LinkHighlight.cpp +++ b/Source/web/LinkHighlight.cpp @@ -32,11 +32,11 @@ #include "WebKit.h" #include "WebViewImpl.h" #include "core/dom/Node.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/platform/graphics/Color.h" +#include "core/rendering/CompositedLayerMapping.h" #include "core/rendering/RenderLayer.h" -#include "core/rendering/RenderLayerBacking.h" #include "core/rendering/RenderLayerModelObject.h" #include "core/rendering/RenderObject.h" #include "core/rendering/RenderView.h" @@ -109,10 +109,9 @@ RenderLayer* LinkHighlight::computeEnclosingCompositingLayer() if (!m_node || !m_node->renderer()) return 0; - // FIXME: There's no need for renderer to be cast to a RLMO. // Find the nearest enclosing composited layer and attach to it. We may need to cross frame boundaries // to find a suitable layer. - RenderLayerModelObject* renderer = toRenderLayerModelObject(m_node->renderer()); + RenderObject* renderer = m_node->renderer(); RenderLayerModelObject* repaintContainer; do { repaintContainer = renderer->containerForRepaint(); @@ -127,13 +126,13 @@ RenderLayer* LinkHighlight::computeEnclosingCompositingLayer() if (!renderLayer || !renderLayer->isComposited()) return 0; - GraphicsLayer* newGraphicsLayer = renderLayer->backing()->graphicsLayer(); + GraphicsLayer* newGraphicsLayer = renderLayer->compositedLayerMapping()->mainGraphicsLayer(); m_clipLayer->setSublayerTransform(SkMatrix44()); if (!newGraphicsLayer->drawsContent()) { if (renderLayer->usesCompositedScrolling()) { - ASSERT(renderLayer->backing() && renderLayer->backing()->scrollingContentsLayer()); - newGraphicsLayer = renderLayer->backing()->scrollingContentsLayer(); + ASSERT(renderLayer->compositedLayerMapping() && renderLayer->compositedLayerMapping()->scrollingContentsLayer()); + newGraphicsLayer = renderLayer->compositedLayerMapping()->scrollingContentsLayer(); } else ASSERT_NOT_REACHED(); } diff --git a/Source/web/LinkHighlight.h b/Source/web/LinkHighlight.h index 0bd1668e7..c51f8ca63 100644 --- a/Source/web/LinkHighlight.h +++ b/Source/web/LinkHighlight.h @@ -26,10 +26,10 @@ #ifndef LinkHighlight_h #define LinkHighlight_h -#include "core/platform/graphics/FloatPoint.h" #include "core/platform/graphics/GraphicsLayer.h" -#include "core/platform/graphics/IntPoint.h" #include "core/platform/graphics/Path.h" +#include "platform/geometry/FloatPoint.h" +#include "platform/geometry/IntPoint.h" #include "public/platform/WebAnimationDelegate.h" #include "public/platform/WebContentLayer.h" #include "public/platform/WebContentLayerClient.h" diff --git a/Source/web/LocalFileSystemClient.cpp b/Source/web/LocalFileSystemClient.cpp index 1ae4e0622..08812bc06 100644 --- a/Source/web/LocalFileSystemClient.cpp +++ b/Source/web/LocalFileSystemClient.cpp @@ -57,7 +57,7 @@ LocalFileSystemClient::~LocalFileSystemClient() { } -bool LocalFileSystemClient::allowFileSystem(ScriptExecutionContext* context) +bool LocalFileSystemClient::allowFileSystem(ExecutionContext* context) { Document* document = toDocument(context); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); diff --git a/Source/web/LocalFileSystemClient.h b/Source/web/LocalFileSystemClient.h index a9f0d5af0..7d4758d98 100644 --- a/Source/web/LocalFileSystemClient.h +++ b/Source/web/LocalFileSystemClient.h @@ -42,7 +42,7 @@ public: virtual ~LocalFileSystemClient(); - virtual bool allowFileSystem(WebCore::ScriptExecutionContext*) OVERRIDE; + virtual bool allowFileSystem(WebCore::ExecutionContext*) OVERRIDE; private: LocalFileSystemClient(); diff --git a/Source/web/NotificationPresenterImpl.cpp b/Source/web/NotificationPresenterImpl.cpp index 32cb6ba36..59b2dcd09 100644 --- a/Source/web/NotificationPresenterImpl.cpp +++ b/Source/web/NotificationPresenterImpl.cpp @@ -34,7 +34,7 @@ #include "WebNotification.h" #include "WebNotificationPermissionCallback.h" #include "WebNotificationPresenter.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "modules/notifications/Notification.h" #include "weborigin/SecurityOrigin.h" #include "wtf/PassRefPtr.h" @@ -118,20 +118,20 @@ void NotificationPresenterImpl::notificationControllerDestroyed() { } -NotificationClient::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context) +NotificationClient::Permission NotificationPresenterImpl::checkPermission(ExecutionContext* context) { int result = m_presenter->checkPermission(WebSecurityOrigin(context->securityOrigin())); return static_cast<NotificationClient::Permission>(result); } #if ENABLE(LEGACY_NOTIFICATIONS) -void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback) +void NotificationPresenterImpl::requestPermission(ExecutionContext* context, PassRefPtr<VoidCallback> callback) { m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new VoidCallbackClient(callback)); } #endif // ENABLE(LEGACY_NOTIFICATIONS) -void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, WTF::PassRefPtr<NotificationPermissionCallback> callback) +void NotificationPresenterImpl::requestPermission(ExecutionContext* context, WTF::PassRefPtr<NotificationPermissionCallback> callback) { m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new NotificationPermissionCallbackClient(m_presenter, context->securityOrigin(), callback)); } diff --git a/Source/web/NotificationPresenterImpl.h b/Source/web/NotificationPresenterImpl.h index 59a168843..a116ffad4 100644 --- a/Source/web/NotificationPresenterImpl.h +++ b/Source/web/NotificationPresenterImpl.h @@ -53,12 +53,12 @@ public: virtual void cancel(WebCore::Notification* object); virtual void notificationObjectDestroyed(WebCore::Notification* object); virtual void notificationControllerDestroyed(); - virtual WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*); + virtual WebCore::NotificationClient::Permission checkPermission(WebCore::ExecutionContext*); #if ENABLE(LEGACY_NOTIFICATIONS) - virtual void requestPermission(WebCore::ScriptExecutionContext*, WTF::PassRefPtr<WebCore::VoidCallback> callback); + virtual void requestPermission(WebCore::ExecutionContext*, WTF::PassRefPtr<WebCore::VoidCallback>); #endif - virtual void requestPermission(WebCore::ScriptExecutionContext*, WTF::PassRefPtr<WebCore::NotificationPermissionCallback>); - virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) {} + virtual void requestPermission(WebCore::ExecutionContext*, WTF::PassRefPtr<WebCore::NotificationPermissionCallback>); + virtual void cancelRequestsForPermission(WebCore::ExecutionContext*) { } private: // WebNotificationPresenter that this object delegates to. diff --git a/Source/web/OWNERS b/Source/web/OWNERS index 042121893..3af0dc096 100644 --- a/Source/web/OWNERS +++ b/Source/web/OWNERS @@ -4,14 +4,15 @@ darin@chromium.org dglazkov@chromium.org jamesr@chromium.org jochen@chromium.org +ojan@chromium.org +pfeldman@chromium.org tkent@chromium.org tony@chromium.org -pfeldman@chromium.org # Bindings owners for WebBindings.cpp per-file WebBindings.cpp=adamk@chromium.org per-file WebBindings.cpp=arv@chromium.org -per-file WebBindings.cpp=ch.dumez@sisa.samsung.com +per-file WebBindings.cpp=ch.dumez@samsung.com per-file WebBindings.cpp=dcarney@chromium.org per-file WebBindings.cpp=esprehn@chromium.org per-file WebBindings.cpp=haraken@chromium.org diff --git a/Source/web/PageScaleConstraintsSet.cpp b/Source/web/PageScaleConstraintsSet.cpp new file mode 100644 index 000000000..582c27fce --- /dev/null +++ b/Source/web/PageScaleConstraintsSet.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PageScaleConstraintsSet.h" + +#include "wtf/Assertions.h" + +using namespace WebCore; + +namespace WebKit { + +static const float defaultMinimumScale = 0.25f; +static const float defaultMaximumScale = 5.0f; + +PageScaleConstraintsSet::PageScaleConstraintsSet() + : m_lastContentsWidth(0) + , m_needsReset(false) + , m_constraintsDirty(false) +{ + m_finalConstraints = defaultConstraints(); +} + +PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const +{ + return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale); +} + +void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportDescription& description, IntSize viewSize) +{ + m_pageDefinedConstraints = description.resolve(viewSize); + + m_constraintsDirty = true; +} + +void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints& userAgentConstraints) +{ + m_userAgentConstraints = userAgentConstraints; + m_constraintsDirty = true; +} + +void PageScaleConstraintsSet::computeFinalConstraints() +{ + m_finalConstraints = defaultConstraints(); + m_finalConstraints.overrideWith(m_pageDefinedConstraints); + m_finalConstraints.overrideWith(m_userAgentConstraints); + + m_constraintsDirty = false; +} + +void PageScaleConstraintsSet::adjustFinalConstraintsToContentsSize(IntSize viewSize, IntSize contentsSize, int nonOverlayScrollbarWidth) +{ + m_finalConstraints.fitToContentsWidth(contentsSize.width(), viewSize.width() - nonOverlayScrollbarWidth); +} + +void PageScaleConstraintsSet::setNeedsReset(bool needsReset) +{ + m_needsReset = needsReset; + if (needsReset) + m_constraintsDirty = true; +} + +void PageScaleConstraintsSet::didChangeContentsSize(IntSize contentsSize, float pageScaleFactor) +{ + // If a large fixed-width element expanded the size of the document + // late in loading and our initial scale is not constrained, reset the + // page scale factor to the new minimum scale. + if (contentsSize.width() > m_lastContentsWidth + && pageScaleFactor == finalConstraints().minimumScale + && userAgentConstraints().initialScale == -1 && pageDefinedConstraints().initialScale == -1) + setNeedsReset(true); + + m_constraintsDirty = true; + m_lastContentsWidth = contentsSize.width(); +} + +static float computeDeprecatedTargetDensityDPIFactor(const ViewportDescription& description, float deviceScaleFactor) +{ + if (description.deprecatedTargetDensityDPI == ViewportDescription::ValueDeviceDPI) + return 1.0f / deviceScaleFactor; + + float targetDPI = -1.0f; + if (description.deprecatedTargetDensityDPI == ViewportDescription::ValueLowDPI) + targetDPI = 120.0f; + else if (description.deprecatedTargetDensityDPI == ViewportDescription::ValueMediumDPI) + targetDPI = 160.0f; + else if (description.deprecatedTargetDensityDPI == ViewportDescription::ValueHighDPI) + targetDPI = 240.0f; + else if (description.deprecatedTargetDensityDPI != ViewportDescription::ValueAuto) + targetDPI = description.deprecatedTargetDensityDPI; + return targetDPI > 0 ? 160.0f / targetDPI : 1.0f; +} + +static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale) +{ + return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initialScale; +} + +void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescription& description, IntSize viewSize, int layoutFallbackWidth, float deviceScaleFactor, bool supportTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWideViewport, bool loadWithOverviewMode) +{ + if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOverviewMode) + return; + + const float oldInitialScale = m_pageDefinedConstraints.initialScale; + if (!loadWithOverviewMode) { + bool resetInitialScale = false; + if (description.zoom == -1) { + if (description.maxWidth.isAuto()) + resetInitialScale = true; + if (useWideViewport || !description.maxWidth.isFixed()) + resetInitialScale = true; + } + if (resetInitialScale) + m_pageDefinedConstraints.initialScale = 1.0f; + } + + float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); + float targetDensityDPIFactor = 1.0f; + + if (supportTargetDensityDPI) { + targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(description, deviceScaleFactor); + if (m_pageDefinedConstraints.initialScale != -1) + m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; + m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; + m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; + if (wideViewportQuirkEnabled && (!useWideViewport || !description.maxWidth.isFixed())) + adjustedLayoutSizeWidth /= targetDensityDPIFactor; + } + + if (wideViewportQuirkEnabled) { + if (useWideViewport && (description.maxWidth.isAuto() || description.maxWidth.type() == ExtendToZoom) && description.zoom != 1.0f) { + adjustedLayoutSizeWidth = layoutFallbackWidth; + } else if (!useWideViewport) { + const float nonWideScale = description.zoom < 1 && !description.maxWidth.isViewportPercentage() ? -1 : oldInitialScale; + adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, nonWideScale) / targetDensityDPIFactor; + if (description.zoom < 1) { + m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; + m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDefinedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); + m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDefinedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); + } + } + } + + if (oldInitialScale != m_pageDefinedConstraints.initialScale && m_pageDefinedConstraints.initialScale != -1) + setNeedsReset(true); + + if (adjustedLayoutSizeWidth != m_pageDefinedConstraints.layoutSize.width()) { + ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); + float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedConstraints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); + m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); + m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); + } +} + +} // namespace WebCore diff --git a/Source/web/PageScaleConstraintsSet.h b/Source/web/PageScaleConstraintsSet.h new file mode 100644 index 000000000..4906fe522 --- /dev/null +++ b/Source/web/PageScaleConstraintsSet.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PageScaleConstraintsSet_h +#define PageScaleConstraintsSet_h + +#include "core/dom/ViewportDescription.h" +#include "core/page/PageScaleConstraints.h" +#include "platform/geometry/IntSize.h" + +namespace WebKit { + +// This class harmonizes the viewport (particularly page scale) constraints from +// the meta viewport tag and other sources. +class PageScaleConstraintsSet { +public: + PageScaleConstraintsSet(); + + WebCore::PageScaleConstraints defaultConstraints() const; + + // Settings defined in the website's viewport tag, if viewport tag support + // is enabled. + const WebCore::PageScaleConstraints& pageDefinedConstraints() const { return m_pageDefinedConstraints; } + void updatePageDefinedConstraints(const WebCore::ViewportDescription&, WebCore::IntSize viewSize); + void adjustForAndroidWebViewQuirks(const WebCore::ViewportDescription&, WebCore::IntSize viewSize, int layoutFallbackWidth, float deviceScaleFactor, bool supportTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWideViewport, bool loadWithOverviewMode); + + // Constraints may also be set from Chromium -- this overrides any + // page-defined values. + const WebCore::PageScaleConstraints& userAgentConstraints() const { return m_userAgentConstraints; } + void setUserAgentConstraints(const WebCore::PageScaleConstraints&); + + // Actual computed values, taking into account the above plus the current + // viewport size and document width. + const WebCore::PageScaleConstraints& finalConstraints() const { return m_finalConstraints; } + void computeFinalConstraints(); + void adjustFinalConstraintsToContentsSize(WebCore::IntSize viewSize, WebCore::IntSize contentsSize, int nonOverlayScrollbarWidth); + + void didChangeContentsSize(WebCore::IntSize contentsSize, float pageScaleFactor); + + // This should be set to true on each page load to note that the page scale + // factor needs to be reset to its initial value. + void setNeedsReset(bool); + bool needsReset() const { return m_needsReset; } + + // This is set when one of the inputs to finalConstraints changes. + bool constraintsDirty() const { return m_constraintsDirty; } + +private: + WebCore::PageScaleConstraints m_pageDefinedConstraints; + WebCore::PageScaleConstraints m_userAgentConstraints; + WebCore::PageScaleConstraints m_finalConstraints; + + int m_lastContentsWidth; + + bool m_needsReset; + bool m_constraintsDirty; +}; + +} // namespace WebCore + +#endif // PageScaleConstraintsSet_h diff --git a/Source/web/PageWidgetDelegate.cpp b/Source/web/PageWidgetDelegate.cpp index 9bf0defcd..a5e7765a7 100644 --- a/Source/web/PageWidgetDelegate.cpp +++ b/Source/web/PageWidgetDelegate.cpp @@ -35,8 +35,8 @@ #include "WebInputEvent.h" #include "WebInputEventConversion.h" #include "core/page/EventHandler.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/platform/graphics/GraphicsContext.h" #include "wtf/CurrentTime.h" @@ -153,6 +153,7 @@ bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& ha case WebInputEvent::GestureTap: case WebInputEvent::GestureTapUnconfirmed: case WebInputEvent::GestureTapDown: + case WebInputEvent::GestureShowPress: case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureTwoFingerTap: diff --git a/Source/web/PinchViewports.cpp b/Source/web/PinchViewports.cpp index b139a32ed..6dcb557d4 100644 --- a/Source/web/PinchViewports.cpp +++ b/Source/web/PinchViewports.cpp @@ -33,13 +33,13 @@ #include "WebSettingsImpl.h" #include "WebViewImpl.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/scrolling/ScrollingCoordinator.h" #include "core/platform/Scrollbar.h" -#include "core/platform/graphics/FloatSize.h" #include "core/platform/graphics/GraphicsLayer.h" #include "core/rendering/RenderLayerCompositor.h" +#include "platform/geometry/FloatSize.h" #include "public/platform/Platform.h" #include "public/platform/WebCompositorSupport.h" #include "public/platform/WebLayer.h" diff --git a/Source/web/PinchViewports.h b/Source/web/PinchViewports.h index a26cf4601..15f90f853 100644 --- a/Source/web/PinchViewports.h +++ b/Source/web/PinchViewports.h @@ -32,7 +32,7 @@ #define PinchViewports_h #include "core/platform/graphics/GraphicsLayerClient.h" -#include "core/platform/graphics/IntSize.h" +#include "platform/geometry/IntSize.h" #include "public/platform/WebScrollbar.h" #include "public/platform/WebSize.h" #include "wtf/OwnPtr.h" diff --git a/Source/web/PopupContainer.cpp b/Source/web/PopupContainer.cpp index d5ca9ca87..faf41dce5 100644 --- a/Source/web/PopupContainer.cpp +++ b/Source/web/PopupContainer.cpp @@ -33,23 +33,23 @@ #include "PopupListBox.h" #include "core/dom/Document.h" -#include "core/dom/UserGestureIndicator.h" #include "core/page/Chrome.h" #include "core/page/ChromeClient.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" -#include "core/platform/PlatformGestureEvent.h" -#include "core/platform/PlatformKeyboardEvent.h" -#include "core/platform/PlatformMouseEvent.h" #include "core/platform/PlatformScreen.h" -#include "core/platform/PlatformTouchEvent.h" -#include "core/platform/PlatformWheelEvent.h" #include "core/platform/PopupMenuClient.h" #include "core/platform/chromium/FramelessScrollView.h" #include "core/platform/chromium/FramelessScrollViewClient.h" #include "core/platform/graphics/GraphicsContext.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/PlatformGestureEvent.h" +#include "platform/PlatformKeyboardEvent.h" +#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformTouchEvent.h" +#include "platform/PlatformWheelEvent.h" +#include "platform/UserGestureIndicator.h" +#include "platform/geometry/IntRect.h" #include <limits> namespace WebCore { @@ -306,6 +306,7 @@ bool PopupContainer::handleGestureEvent(const PlatformGestureEvent& gestureEvent case PlatformEvent::GestureScrollBegin: case PlatformEvent::GestureScrollEnd: case PlatformEvent::GestureTapDown: + case PlatformEvent::GestureShowPress: break; default: ASSERT_NOT_REACHED(); diff --git a/Source/web/PopupContainer.h b/Source/web/PopupContainer.h index 87d9fbf19..02be42fe0 100644 --- a/Source/web/PopupContainer.h +++ b/Source/web/PopupContainer.h @@ -34,7 +34,7 @@ #include "PopupListBox.h" #include "core/platform/PopupMenuStyle.h" #include "core/platform/chromium/FramelessScrollView.h" -#include "core/platform/graphics/FloatQuad.h" +#include "platform/geometry/FloatQuad.h" namespace WebCore { diff --git a/Source/web/PopupListBox.cpp b/Source/web/PopupListBox.cpp index 39fc26139..f45413735 100644 --- a/Source/web/PopupListBox.cpp +++ b/Source/web/PopupListBox.cpp @@ -35,12 +35,7 @@ #include "PopupContainer.h" #include "PopupMenuChromium.h" #include "RuntimeEnabledFeatures.h" -#include "core/platform/PlatformGestureEvent.h" -#include "core/platform/PlatformKeyboardEvent.h" -#include "core/platform/PlatformMouseEvent.h" #include "core/platform/PlatformScreen.h" -#include "core/platform/PlatformTouchEvent.h" -#include "core/platform/PlatformWheelEvent.h" #include "core/platform/PopupMenuClient.h" #include "core/platform/ScrollbarTheme.h" #include "core/platform/chromium/FramelessScrollViewClient.h" @@ -49,10 +44,15 @@ #include "core/platform/graphics/FontCache.h" #include "core/platform/graphics/FontSelector.h" #include "core/platform/graphics/GraphicsContext.h" -#include "core/platform/graphics/IntRect.h" #include "core/platform/graphics/StringTruncator.h" -#include "core/platform/graphics/TextRun.h" #include "core/rendering/RenderTheme.h" +#include "platform/PlatformGestureEvent.h" +#include "platform/PlatformKeyboardEvent.h" +#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformTouchEvent.h" +#include "platform/PlatformWheelEvent.h" +#include "platform/geometry/IntRect.h" +#include "platform/graphics/TextRun.h" #include "wtf/ASCIICType.h" #include "wtf/CurrentTime.h" #include <limits> @@ -143,8 +143,8 @@ bool PopupListBox::handleMouseReleaseEvent(const PlatformMouseEvent& event) // be removed in acceptIndex() calling because of event handler. bool isSelectPopup = m_popupClient->menuStyle().menuType() == PopupMenuStyle::SelectPopup; if (acceptIndex(pointToRowIndex(event.position())) && m_focusedElement && isSelectPopup) { - m_focusedElement->dispatchMouseEvent(event, eventNames().mouseupEvent); - m_focusedElement->dispatchMouseEvent(event, eventNames().clickEvent); + m_focusedElement->dispatchMouseEvent(event, EventTypeNames::mouseup); + m_focusedElement->dispatchMouseEvent(event, EventTypeNames::click); // Clear m_focusedElement here, because we cannot clear in hidePopup() // which is called before dispatchMouseEvent() is called. @@ -406,7 +406,7 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd backColor = style.backgroundColor(); textColor = style.foregroundColor(); -#if OS(LINUX) +#if OS(LINUX) || OS(ANDROID) // On other platforms, the <option> background color is the same as the // <select> background color. On Linux, that makes the <option> // background color very dark, so by default, try to use a lighter diff --git a/Source/web/PopupListBox.h b/Source/web/PopupListBox.h index 01641bce3..34a94438d 100644 --- a/Source/web/PopupListBox.h +++ b/Source/web/PopupListBox.h @@ -33,7 +33,7 @@ #include "core/dom/Element.h" #include "core/platform/chromium/FramelessScrollView.h" -#include "core/platform/text/TextDirection.h" +#include "platform/text/TextDirection.h" #include "wtf/text/WTFString.h" namespace WebCore { diff --git a/Source/web/PopupMenuChromium.cpp b/Source/web/PopupMenuChromium.cpp index 38bbeb00f..07974f174 100644 --- a/Source/web/PopupMenuChromium.cpp +++ b/Source/web/PopupMenuChromium.cpp @@ -33,9 +33,8 @@ #include "PopupMenuChromium.h" #include "PopupContainer.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" -#include "core/page/Page.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Settings.h" namespace WebCore { @@ -71,7 +70,7 @@ void PopupMenuChromium::show(const FloatQuad& controlPosition, const IntSize& co { if (!m_popup) { PopupContainerSettings popupSettings = dropDownSettings; - popupSettings.deviceSupportsTouch = m_frameView->frame().page()->settings().deviceSupportsTouch(); + popupSettings.deviceSupportsTouch = m_frameView->frame().settings()->deviceSupportsTouch(); m_popup = PopupContainer::create(client(), PopupContainer::Select, popupSettings); } m_popup->showInRect(controlPosition, controlSize, m_frameView.get(), index); diff --git a/Source/web/PrerendererClientImpl.cpp b/Source/web/PrerendererClientImpl.cpp index 1cf2d40ae..b574244c0 100644 --- a/Source/web/PrerendererClientImpl.cpp +++ b/Source/web/PrerendererClientImpl.cpp @@ -35,8 +35,7 @@ #include "WebPrerendererClient.h" #include "WebViewImpl.h" #include "core/dom/Document.h" -#include "core/platform/PrerenderHandle.h" -#include "core/platform/chromium/Prerender.h" +#include "core/platform/Prerender.h" #include "public/platform/WebPrerender.h" #include "wtf/PassRefPtr.h" @@ -47,11 +46,11 @@ PrerendererClientImpl::PrerendererClientImpl(WebPrerendererClient* client) { } -void PrerendererClientImpl::willAddPrerender(WebCore::PrerenderHandle* prerenderHandle) +void PrerendererClientImpl::willAddPrerender(WebCore::Prerender* prerender) { if (!m_client) return; - WebPrerender webPrerender(prerenderHandle->prerender()); + WebPrerender webPrerender(prerender); m_client->willAddPrerender(&webPrerender); } diff --git a/Source/web/PrerendererClientImpl.h b/Source/web/PrerendererClientImpl.h index 9568619b5..05bf024d3 100644 --- a/Source/web/PrerendererClientImpl.h +++ b/Source/web/PrerendererClientImpl.h @@ -37,7 +37,7 @@ #include "wtf/PassRefPtr.h" namespace WebCore { -class PrerenderHandle; +class Prerender; } namespace WebKit { @@ -49,7 +49,7 @@ class PrerendererClientImpl : public WebCore::PrerendererClient { public: explicit PrerendererClientImpl(WebPrerendererClient*); - void willAddPrerender(WebCore::PrerenderHandle*) OVERRIDE; + void willAddPrerender(WebCore::Prerender*) OVERRIDE; private: WebPrerendererClient* m_client; diff --git a/Source/web/ScrollbarGroup.cpp b/Source/web/ScrollbarGroup.cpp index b92b1ee92..e2f232f44 100644 --- a/Source/web/ScrollbarGroup.cpp +++ b/Source/web/ScrollbarGroup.cpp @@ -27,7 +27,7 @@ #include "ScrollbarGroup.h" #include "WebPluginScrollbarImpl.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/platform/Scrollbar.h" #include "core/platform/ScrollbarTheme.h" #include "public/platform/WebRect.h" @@ -158,7 +158,7 @@ IntPoint ScrollbarGroup::convertFromContainingViewToScrollbar(const Scrollbar* s return m_horizontalScrollbar->convertFromContainingViewToScrollbar(parentPoint); if (m_verticalScrollbar && scrollbar == m_verticalScrollbar->scrollbar()) return m_verticalScrollbar->convertFromContainingViewToScrollbar(parentPoint); - WEBKIT_ASSERT_NOT_REACHED(); + BLINK_ASSERT_NOT_REACHED(); return IntPoint(); } @@ -195,7 +195,7 @@ int ScrollbarGroup::visibleHeight() const return m_verticalScrollbar->scrollbar()->height(); if (m_horizontalScrollbar) return m_horizontalScrollbar->scrollbar()->height(); - WEBKIT_ASSERT_NOT_REACHED(); + BLINK_ASSERT_NOT_REACHED(); return 0; } @@ -205,7 +205,7 @@ int ScrollbarGroup::visibleWidth() const return m_horizontalScrollbar->scrollbar()->width(); if (m_verticalScrollbar) return m_verticalScrollbar->scrollbar()->width(); - WEBKIT_ASSERT_NOT_REACHED(); + BLINK_ASSERT_NOT_REACHED(); return 0; } diff --git a/Source/web/SharedWorkerRepository.cpp b/Source/web/SharedWorkerRepository.cpp index d295a9f72..b77b3d143 100644 --- a/Source/web/SharedWorkerRepository.cpp +++ b/Source/web/SharedWorkerRepository.cpp @@ -37,15 +37,15 @@ #include "WebKit.h" #include "WebSharedWorker.h" #include "WebSharedWorkerRepository.h" +#include "bindings/v8/ExceptionMessages.h" #include "bindings/v8/ExceptionState.h" -#include "core/events/Event.h" -#include "core/events/EventNames.h" #include "core/dom/ExceptionCode.h" +#include "core/dom/ExecutionContext.h" #include "core/dom/MessagePortChannel.h" -#include "core/dom/ScriptExecutionContext.h" -#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h" +#include "core/events/Event.h" +#include "core/events/ThreadLocalEventNames.h" +#include "core/frame/ContentSecurityPolicy.h" #include "core/inspector/InspectorInstrumentation.h" -#include "core/page/ContentSecurityPolicy.h" #include "core/platform/network/ResourceResponse.h" #include "core/workers/SharedWorker.h" #include "core/workers/WorkerScriptLoader.h" @@ -84,12 +84,12 @@ using WebKit::WebSharedWorkerRepository; // Callback class that keeps the SharedWorker and WebSharedWorker objects alive while loads are potentially happening, and also translates load errors into error events on the worker. class SharedWorkerScriptLoader : private WorkerScriptLoaderClient, private WebSharedWorker::ConnectListener { public: - SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker) + SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassRefPtr<MessagePortChannel> channel, PassOwnPtr<WebSharedWorker> webWorker) : m_worker(worker) , m_url(url) , m_name(name) , m_webWorker(webWorker) - , m_port(port) + , m_channel(channel) , m_scriptLoader(WorkerScriptLoader::create()) , m_loading(false) , m_responseAppCacheID(0) @@ -99,7 +99,7 @@ public: ~SharedWorkerScriptLoader(); void load(); - static void stopAllLoadersForContext(ScriptExecutionContext*); + static void stopAllLoadersForContext(ExecutionContext*); private: // WorkerScriptLoaderClient callbacks @@ -108,7 +108,7 @@ private: virtual void connected(); - const ScriptExecutionContext* loadingContext() { return m_worker->scriptExecutionContext(); } + const ExecutionContext* loadingContext() { return m_worker->executionContext(); } void sendConnect(); @@ -116,7 +116,7 @@ private: KURL m_url; String m_name; OwnPtr<WebSharedWorker> m_webWorker; - OwnPtr<MessagePortChannel> m_port; + RefPtr<MessagePortChannel> m_channel; RefPtr<WorkerScriptLoader> m_scriptLoader; bool m_loading; long long m_responseAppCacheID; @@ -128,7 +128,7 @@ static Vector<SharedWorkerScriptLoader*>& pendingLoaders() return loaders; } -void SharedWorkerScriptLoader::stopAllLoadersForContext(ScriptExecutionContext* context) +void SharedWorkerScriptLoader::stopAllLoadersForContext(ExecutionContext* context) { // Walk our list of pending loaders and shutdown any that belong to this context. Vector<SharedWorkerScriptLoader*>& loaders = pendingLoaders(); @@ -159,46 +159,35 @@ void SharedWorkerScriptLoader::load() m_worker->setPendingActivity(m_worker.get()); m_loading = true; - m_scriptLoader->loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this); + m_scriptLoader->loadAsynchronously(m_worker->executionContext(), m_url, DenyCrossOriginRequests, this); } } -// Extracts a WebMessagePortChannel from a MessagePortChannel. -static WebMessagePortChannel* getWebPort(PassOwnPtr<MessagePortChannel> port) -{ - // Extract the WebMessagePortChannel to send to the worker. - PlatformMessagePortChannel* platformChannel = port->channel(); - WebMessagePortChannel* webPort = platformChannel->webChannelRelease(); - webPort->setClient(0); - return webPort; -} - void SharedWorkerScriptLoader::didReceiveResponse(unsigned long identifier, const ResourceResponse& response) { m_responseAppCacheID = response.appCacheID(); - InspectorInstrumentation::didReceiveScriptResponse(m_worker->scriptExecutionContext(), identifier); + InspectorInstrumentation::didReceiveScriptResponse(m_worker->executionContext(), identifier); } void SharedWorkerScriptLoader::notifyFinished() { if (m_scriptLoader->failed()) { - m_worker->dispatchEvent(Event::createCancelable(eventNames().errorEvent)); + m_worker->dispatchEvent(Event::createCancelable(EventTypeNames::error)); delete this; } else { - InspectorInstrumentation::scriptImported(m_worker->scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); + InspectorInstrumentation::scriptImported(m_worker->executionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); // Pass the script off to the worker, then send a connect event. - m_webWorker->startWorkerContext(m_url, m_name, m_worker->scriptExecutionContext()->userAgent(m_url), m_scriptLoader->script(), - m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeader(), - static_cast<WebKit::WebContentSecurityPolicyType>(m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeaderType()), - m_responseAppCacheID); + m_webWorker->startWorkerContext(m_url, m_name, m_worker->executionContext()->userAgent(m_url), m_scriptLoader->script(), m_worker->executionContext()->contentSecurityPolicy()->deprecatedHeader(), static_cast<WebKit::WebContentSecurityPolicyType>(m_worker->executionContext()->contentSecurityPolicy()->deprecatedHeaderType()), m_responseAppCacheID); sendConnect(); } } void SharedWorkerScriptLoader::sendConnect() { + WebMessagePortChannel* webChannel = m_channel->webChannelRelease(); + m_channel.clear(); // Send the connect event off, and linger until it is done sending. - m_webWorker->connect(getWebPort(m_port.release()), this); + m_webWorker->connect(webChannel, this); } void SharedWorkerScriptLoader::connected() @@ -218,7 +207,7 @@ static WebSharedWorkerRepository::DocumentID getId(void* document) return reinterpret_cast<WebSharedWorkerRepository::DocumentID>(document); } -void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionState& es) +void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassRefPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionState& es) { WebKit::WebSharedWorkerRepository* repository = WebKit::sharedWorkerRepository(); @@ -227,15 +216,15 @@ void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr ASSERT(repository); // No nested workers (for now) - connect() should only be called from document context. - ASSERT(worker->scriptExecutionContext()->isDocument()); - Document* document = toDocument(worker->scriptExecutionContext()); + ASSERT(worker->executionContext()->isDocument()); + Document* document = toDocument(worker->executionContext()); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); OwnPtr<WebSharedWorker> webWorker; webWorker = adoptPtr(webFrame->client()->createSharedWorker(webFrame, url, name, getId(document))); if (!webWorker) { // Existing worker does not match this url, so return an error back to the caller. - es.throwUninformativeAndGenericDOMException(URLMismatchError); + es.throwDOMException(URLMismatchError, ExceptionMessages::failedToConstruct("SharedWorker", "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL ('" + url.elidedString() + "').")); return; } diff --git a/Source/web/SpeechInputClientImpl.cpp b/Source/web/SpeechInputClientImpl.cpp index 227de32b2..7738964d2 100644 --- a/Source/web/SpeechInputClientImpl.cpp +++ b/Source/web/SpeechInputClientImpl.cpp @@ -37,7 +37,7 @@ #include "WebSecurityOrigin.h" #include "WebSpeechInputController.h" #include "WebViewClient.h" -#include "core/page/SpeechInputListener.h" +#include "core/speech/SpeechInputListener.h" #include "weborigin/SecurityOrigin.h" #if ENABLE(INPUT_SPEECH) diff --git a/Source/web/SpeechInputClientImpl.h b/Source/web/SpeechInputClientImpl.h index 542293c2c..e25821147 100644 --- a/Source/web/SpeechInputClientImpl.h +++ b/Source/web/SpeechInputClientImpl.h @@ -34,7 +34,7 @@ #if ENABLE(INPUT_SPEECH) #include "WebSpeechInputListener.h" -#include "core/page/SpeechInputClient.h" +#include "core/speech/SpeechInputClient.h" #include "wtf/Forward.h" #include "wtf/OwnPtr.h" #include "wtf/PassOwnPtr.h" diff --git a/Source/web/SpeechRecognitionClientProxy.cpp b/Source/web/SpeechRecognitionClientProxy.cpp index a5b617253..3ae6d9109 100644 --- a/Source/web/SpeechRecognitionClientProxy.cpp +++ b/Source/web/SpeechRecognitionClientProxy.cpp @@ -34,7 +34,7 @@ #include "WebSpeechRecognitionParams.h" #include "WebSpeechRecognitionResult.h" #include "WebSpeechRecognizer.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "modules/speech/SpeechGrammarList.h" #include "modules/speech/SpeechRecognition.h" #include "modules/speech/SpeechRecognitionError.h" @@ -61,7 +61,7 @@ void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S for (unsigned long i = 0; i < grammarList->length(); ++i) webSpeechGrammars[i] = grammarList->item(i); - WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, interimResults, maxAlternatives, WebSecurityOrigin(recognition->scriptExecutionContext()->securityOrigin())); + WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, interimResults, maxAlternatives, WebSecurityOrigin(recognition->executionContext()->securityOrigin())); m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, this); } diff --git a/Source/web/StorageAreaProxy.cpp b/Source/web/StorageAreaProxy.cpp index 799fad166..fccadd748 100644 --- a/Source/web/StorageAreaProxy.cpp +++ b/Source/web/StorageAreaProxy.cpp @@ -31,23 +31,23 @@ #include "bindings/v8/ExceptionMessages.h" #include "bindings/v8/ExceptionState.h" #include "core/dom/Document.h" -#include "core/events/EventNames.h" #include "core/dom/ExceptionCode.h" +#include "core/events/ThreadLocalEventNames.h" #include "core/inspector/InspectorInstrumentation.h" -#include "core/page/DOMWindow.h" -#include "core/page/Frame.h" +#include "core/frame/DOMWindow.h" +#include "core/frame/Frame.h" #include "core/page/Page.h" #include "core/page/PageGroup.h" #include "core/storage/Storage.h" #include "core/storage/StorageEvent.h" #include "weborigin/SecurityOrigin.h" -#include "public/platform/WebStorageArea.h" -#include "public/platform/WebString.h" -#include "public/platform/WebURL.h" #include "WebFrameImpl.h" #include "WebPermissionClient.h" #include "WebViewImpl.h" +#include "public/platform/WebStorageArea.h" +#include "public/platform/WebString.h" +#include "public/platform/WebURL.h" namespace WebCore { @@ -99,7 +99,7 @@ void StorageAreaProxy::setItem(const String& key, const String& value, Exception WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK; m_storageArea->setItem(key, value, frame->document()->url(), result); if (result != WebKit::WebStorageArea::ResultOK) - es.throwUninformativeAndGenericDOMException(QuotaExceededError); + es.throwDOMException(QuotaExceededError, ExceptionMessages::failedToExecute("setItem", "Storage", "Setting the value of '" + key + "' exceeded the quota.")); } void StorageAreaProxy::removeItem(const String& key, ExceptionState& es, Frame* frame) @@ -157,7 +157,7 @@ void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) { Storage* storage = frame->domWindow()->optionalLocalStorage(); if (storage && frame->document()->securityOrigin()->equal(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) - frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, pageURL, storage)); + frame->document()->enqueueWindowEvent(StorageEvent::create(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); } InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue, newValue, LocalStorage, securityOrigin); } @@ -187,7 +187,7 @@ void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const Stri for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) { Storage* storage = frame->domWindow()->optionalSessionStorage(); if (storage && frame->document()->securityOrigin()->equal(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) - frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, pageURL, storage)); + frame->document()->enqueueWindowEvent(StorageEvent::create(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); } InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, SessionStorage, securityOrigin); } diff --git a/Source/web/StorageQuotaChromium.cpp b/Source/web/StorageQuotaChromium.cpp index f0b66e7ea..d8c73c2a7 100644 --- a/Source/web/StorageQuotaChromium.cpp +++ b/Source/web/StorageQuotaChromium.cpp @@ -37,7 +37,7 @@ #include "WebWorkerBase.h" #include "core/dom/Document.h" #include "core/dom/ExceptionCode.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerThread.h" #include "modules/quota/StorageErrorCallback.h" @@ -51,22 +51,22 @@ using namespace WebKit; namespace WebCore { // FIXME: Implement this as StorageQuotaClient. -void StorageQuota::requestQuota(ScriptExecutionContext* scriptExecutionContext, unsigned long long newQuotaInBytes, PassRefPtr<StorageQuotaCallback> successCallback, PassRefPtr<StorageErrorCallback> errorCallback) +void StorageQuota::requestQuota(ExecutionContext* executionContext, unsigned long long newQuotaInBytes, PassRefPtr<StorageQuotaCallback> successCallback, PassRefPtr<StorageErrorCallback> errorCallback) { - ASSERT(scriptExecutionContext); + ASSERT(executionContext); WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); if (storageType != WebStorageQuotaTypeTemporary && storageType != WebStorageQuotaTypePersistent) { // Unknown storage type is requested. - scriptExecutionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError)); + executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError)); return; } - if (scriptExecutionContext->isDocument()) { - Document* document = toDocument(scriptExecutionContext); + if (executionContext->isDocument()) { + Document* document = toDocument(executionContext); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); webFrame->client()->requestStorageQuota(webFrame, storageType, newQuotaInBytes, WebStorageQuotaCallbacksImpl::createLeakedPtr(successCallback, errorCallback)); } else { // Requesting quota in Worker is not supported. - scriptExecutionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError)); + executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError)); } } diff --git a/Source/web/ValidationMessageClientImpl.cpp b/Source/web/ValidationMessageClientImpl.cpp index dc30540f8..dc0864df4 100644 --- a/Source/web/ValidationMessageClientImpl.cpp +++ b/Source/web/ValidationMessageClientImpl.cpp @@ -30,13 +30,13 @@ #include "WebValidationMessageClient.h" #include "WebViewImpl.h" #include "core/dom/Element.h" -#include "core/page/FrameView.h" -#include "core/platform/HostWindow.h" +#include "core/frame/FrameView.h" #include "core/rendering/RenderObject.h" -#include "wtf/CurrentTime.h" +#include "platform/HostWindow.h" #include "public/platform/WebRect.h" #include "public/platform/WebString.h" #include "public/web/WebViewClient.h" +#include "wtf/CurrentTime.h" using namespace WebCore; @@ -119,7 +119,7 @@ bool ValidationMessageClientImpl::isValidationMessageVisible(const Element& anch void ValidationMessageClientImpl::documentDetached(const Document& document) { - if (m_currentAnchor && &m_currentAnchor->document() == &document) + if (m_currentAnchor && m_currentAnchor->document() == document) hideValidationMessage(*m_currentAnchor); } diff --git a/Source/web/ValidationMessageClientImpl.h b/Source/web/ValidationMessageClientImpl.h index 65d48d50d..491477f2d 100644 --- a/Source/web/ValidationMessageClientImpl.h +++ b/Source/web/ValidationMessageClientImpl.h @@ -27,8 +27,8 @@ #define ValidationMessageClientImpl_h #include "core/page/ValidationMessageClient.h" -#include "core/platform/Timer.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/Timer.h" +#include "platform/geometry/IntRect.h" #include "wtf/text/WTFString.h" namespace WebCore { diff --git a/Source/web/ViewportAnchor.h b/Source/web/ViewportAnchor.h index ab6860922..51d670082 100644 --- a/Source/web/ViewportAnchor.h +++ b/Source/web/ViewportAnchor.h @@ -31,10 +31,10 @@ #ifndef ViewportAnchor_h #define ViewportAnchor_h -#include "core/platform/graphics/FloatSize.h" -#include "core/platform/graphics/IntPoint.h" -#include "core/platform/graphics/IntRect.h" -#include "core/platform/graphics/LayoutRect.h" +#include "platform/geometry/FloatSize.h" +#include "platform/geometry/IntPoint.h" +#include "platform/geometry/IntRect.h" +#include "platform/geometry/LayoutRect.h" #include "wtf/RefCounted.h" namespace WebCore { diff --git a/Source/web/WebAXObject.cpp b/Source/web/WebAXObject.cpp index 0eb76d890..4b23050bc 100644 --- a/Source/web/WebAXObject.cpp +++ b/Source/web/WebAXObject.cpp @@ -44,9 +44,9 @@ #include "core/dom/Document.h" #include "core/dom/Node.h" #include "core/page/EventHandler.h" -#include "core/page/FrameView.h" -#include "core/platform/PlatformKeyboardEvent.h" +#include "core/frame/FrameView.h" #include "core/rendering/style/RenderStyle.h" +#include "platform/PlatformKeyboardEvent.h" #include "public/platform/WebPoint.h" #include "public/platform/WebRect.h" #include "public/platform/WebString.h" @@ -904,7 +904,7 @@ unsigned WebAXObject::rowIndex() const if (!m_private->isTableRow()) return 0; - return static_cast<WebCore::AccessibilityTableRow*>(m_private.get())->rowIndex(); + return WebCore::toAccessibilityTableRow(m_private.get())->rowIndex(); } WebAXObject WebAXObject::rowHeader() const @@ -915,7 +915,7 @@ WebAXObject WebAXObject::rowHeader() const if (!m_private->isTableRow()) return WebAXObject(); - return WebAXObject(static_cast<WebCore::AccessibilityTableRow*>(m_private.get())->headerObject()); + return WebAXObject(WebCore::toAccessibilityTableRow(m_private.get())->headerObject()); } unsigned WebAXObject::columnIndex() const @@ -926,7 +926,7 @@ unsigned WebAXObject::columnIndex() const if (m_private->roleValue() != ColumnRole) return 0; - return static_cast<WebCore::AccessibilityTableColumn*>(m_private.get())->columnIndex(); + return WebCore::toAccessibilityTableColumn(m_private.get())->columnIndex(); } WebAXObject WebAXObject::columnHeader() const @@ -937,7 +937,7 @@ WebAXObject WebAXObject::columnHeader() const if (m_private->roleValue() != ColumnRole) return WebAXObject(); - return WebAXObject(static_cast<WebCore::AccessibilityTableColumn*>(m_private.get())->headerObject()); + return WebAXObject(WebCore::toAccessibilityTableColumn(m_private.get())->headerObject()); } unsigned WebAXObject::cellColumnIndex() const @@ -949,7 +949,7 @@ unsigned WebAXObject::cellColumnIndex() const return 0; pair<unsigned, unsigned> columnRange; - static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->columnIndexRange(columnRange); + WebCore::toAccessibilityTableCell(m_private.get())->columnIndexRange(columnRange); return columnRange.first; } @@ -962,7 +962,7 @@ unsigned WebAXObject::cellColumnSpan() const return 0; pair<unsigned, unsigned> columnRange; - static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->columnIndexRange(columnRange); + WebCore::toAccessibilityTableCell(m_private.get())->columnIndexRange(columnRange); return columnRange.second; } @@ -975,7 +975,7 @@ unsigned WebAXObject::cellRowIndex() const return 0; pair<unsigned, unsigned> rowRange; - static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->rowIndexRange(rowRange); + WebCore::toAccessibilityTableCell(m_private.get())->rowIndexRange(rowRange); return rowRange.first; } @@ -988,7 +988,7 @@ unsigned WebAXObject::cellRowSpan() const return 0; pair<unsigned, unsigned> rowRange; - static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->rowIndexRange(rowRange); + WebCore::toAccessibilityTableCell(m_private.get())->rowIndexRange(rowRange); return rowRange.second; } diff --git a/Source/web/WebBindings.cpp b/Source/web/WebBindings.cpp index 3301ab39f..3c26df81e 100644 --- a/Source/web/WebBindings.cpp +++ b/Source/web/WebBindings.cpp @@ -45,8 +45,8 @@ #include "bindings/v8/npruntime_impl.h" #include "bindings/v8/npruntime_priv.h" #include "core/dom/Range.h" -#include "core/page/DOMWindow.h" -#include "core/page/Frame.h" +#include "core/frame/DOMWindow.h" +#include "core/frame/Frame.h" #include "public/platform/WebArrayBuffer.h" #include "wtf/ArrayBufferView.h" diff --git a/Source/web/WebBlob.cpp b/Source/web/WebBlob.cpp index 3fb90d128..c3936a2e9 100644 --- a/Source/web/WebBlob.cpp +++ b/Source/web/WebBlob.cpp @@ -45,7 +45,7 @@ WebBlob WebBlob::createFromFile(const WebString& path, long long size) { OwnPtr<BlobData> blobData = BlobData::create(); blobData->appendFile(path); - RefPtr<Blob> blob = Blob::create(blobData.release(), size); + RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(), size)); return WebBlob(blob); } @@ -70,11 +70,11 @@ void WebBlob::assign(const WebBlob& other) m_private = other.m_private; } -WebURL WebBlob::url() +WebString WebBlob::uuid() { if (!m_private.get()) - return WebURL(); - return m_private->url(); + return WebString(); + return m_private->uuid(); } v8::Handle<v8::Value> WebBlob::toV8Value() diff --git a/Source/web/WebBlobData.cpp b/Source/web/WebBlobData.cpp index 65d44a3a1..4a43959fd 100644 --- a/Source/web/WebBlobData.cpp +++ b/Source/web/WebBlobData.cpp @@ -67,7 +67,6 @@ bool WebBlobData::itemAt(size_t index, Item& result) const const BlobDataItem& item = m_private->items()[index]; result.data.reset(); result.filePath.reset(); - result.blobURL = KURL(); result.blobUUID.reset(); result.offset = item.offset; result.length = item.length; @@ -84,13 +83,11 @@ bool WebBlobData::itemAt(size_t index, Item& result) const return true; case BlobDataItem::Blob: result.type = Item::TypeBlob; - result.blobURL = item.url; // FIXME: deprecate this. - result.url = item.url; // DEPRECATED, should be able to remove after https://codereview.chromium.org/23223003/ lands + result.blobUUID = item.blobDataHandle->uuid(); return true; - case BlobDataItem::URL: + case BlobDataItem::FileSystemURL: result.type = Item::TypeFileSystemURL; - result.url = item.url; // DEPRECATED - result.fileSystemURL = item.url; + result.fileSystemURL = item.fileSystemURL; return true; } ASSERT_NOT_REACHED(); diff --git a/Source/web/WebCustomElement.cpp b/Source/web/WebCustomElement.cpp index 1823188b1..f34222e06 100644 --- a/Source/web/WebCustomElement.cpp +++ b/Source/web/WebCustomElement.cpp @@ -33,7 +33,7 @@ #include "../platform/WebString.h" #include "RuntimeEnabledFeatures.h" -#include "core/dom/CustomElement.h" +#include "core/dom/custom/CustomElement.h" using namespace WebCore; diff --git a/Source/web/WebDOMActivityLogger.cpp b/Source/web/WebDOMActivityLogger.cpp index 92e25bf5f..98cd5061c 100644 --- a/Source/web/WebDOMActivityLogger.cpp +++ b/Source/web/WebDOMActivityLogger.cpp @@ -51,10 +51,6 @@ public: virtual void log(const String& apiName, int argc, const v8::Handle<v8::Value>* argv, const String& extraInfo) OVERRIDE { - // FIXME: Delete the first call once matching changes to chromium have - // landed. - m_domActivityLogger->log(WebString(apiName), argc, argv, WebString(extraInfo)); - KURL url; String title; if (Document* document = currentDocument()) { diff --git a/Source/web/WebDOMEvent.cpp b/Source/web/WebDOMEvent.cpp index c2690ba0c..3adf2cde9 100644 --- a/Source/web/WebDOMEvent.cpp +++ b/Source/web/WebDOMEvent.cpp @@ -31,13 +31,11 @@ #include "config.h" #include "WebDOMEvent.h" -#include "core/events/Event.h" -#include "core/events/EventNames.h" +#include "EventNames.h" #include "core/dom/Node.h" +#include "core/events/Event.h" #include "wtf/PassRefPtr.h" -using WebCore::eventNames; - namespace WebKit { class WebDOMEventPrivate : public WebCore::Event { @@ -125,19 +123,19 @@ bool WebDOMEvent::isKeyboardEvent() const bool WebDOMEvent::isMutationEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(WebCore::eventNames().interfaceForMutationEvent); + return m_private->hasInterface(WebCore::EventNames::MutationEvent); } bool WebDOMEvent::isTextEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForTextEvent); + return m_private->hasInterface(WebCore::EventNames::TextEvent); } bool WebDOMEvent::isCompositionEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForCompositionEvent); + return m_private->hasInterface(WebCore::EventNames::CompositionEvent); } bool WebDOMEvent::isDragEvent() const @@ -155,13 +153,13 @@ bool WebDOMEvent::isClipboardEvent() const bool WebDOMEvent::isMessageEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForMessageEvent); + return m_private->hasInterface(WebCore::EventNames::MessageEvent); } bool WebDOMEvent::isWheelEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForWheelEvent); + return m_private->hasInterface(WebCore::EventNames::WheelEvent); } bool WebDOMEvent::isBeforeTextInsertedEvent() const @@ -173,37 +171,37 @@ bool WebDOMEvent::isBeforeTextInsertedEvent() const bool WebDOMEvent::isOverflowEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForOverflowEvent); + return m_private->hasInterface(WebCore::EventNames::OverflowEvent); } bool WebDOMEvent::isPageTransitionEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForPageTransitionEvent); + return m_private->hasInterface(WebCore::EventNames::PageTransitionEvent); } bool WebDOMEvent::isPopStateEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForPopStateEvent); + return m_private->hasInterface(WebCore::EventNames::PopStateEvent); } bool WebDOMEvent::isProgressEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForProgressEvent); + return m_private->hasInterface(WebCore::EventNames::ProgressEvent); } bool WebDOMEvent::isXMLHttpRequestProgressEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgressEvent); + return m_private->hasInterface(WebCore::EventNames::XMLHttpRequestProgressEvent); } bool WebDOMEvent::isBeforeLoadEvent() const { ASSERT(m_private.get()); - return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent); + return m_private->hasInterface(WebCore::EventNames::BeforeLoadEvent); } } // namespace WebKit diff --git a/Source/web/WebDOMFileSystem.cpp b/Source/web/WebDOMFileSystem.cpp new file mode 100644 index 000000000..26e3c45b1 --- /dev/null +++ b/Source/web/WebDOMFileSystem.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebDOMFileSystem.h" + +#include "V8DOMFileSystem.h" +#include "bindings/v8/WrapperTypeInfo.h" +#include "modules/filesystem/DOMFileSystem.h" +#include <v8.h> + +using namespace WebCore; + +namespace WebKit { + +WebDOMFileSystem WebDOMFileSystem::fromV8Value(v8::Handle<v8::Value> value) +{ + if (!V8DOMFileSystem::HasInstanceInAnyWorld(value, v8::Isolate::GetCurrent())) + return WebDOMFileSystem(); + v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); + DOMFileSystem* domFileSystem = V8DOMFileSystem::toNative(object); + ASSERT(domFileSystem); + return WebDOMFileSystem(domFileSystem); +} + +void WebDOMFileSystem::reset() +{ + m_private.reset(); +} + +void WebDOMFileSystem::assign(const WebDOMFileSystem& other) +{ + m_private = other.m_private; +} + +WebString WebDOMFileSystem::name() const +{ + ASSERT(m_private.get()); + return m_private->name(); +} + +WebFileSystem::Type WebDOMFileSystem::type() const +{ + ASSERT(m_private.get()); + switch (m_private->type()) { + case FileSystemTypeTemporary: + return WebFileSystem::TypeTemporary; + case FileSystemTypePersistent: + return WebFileSystem::TypePersistent; + case FileSystemTypeIsolated: + return WebFileSystem::TypeIsolated; + case FileSystemTypeExternal: + return WebFileSystem::TypeExternal; + default: + ASSERT_NOT_REACHED(); + return WebFileSystem::TypeTemporary; + } +} + +WebURL WebDOMFileSystem::rootURL() const +{ + ASSERT(m_private.get()); + return m_private->rootURL(); +} + +WebDOMFileSystem::WebDOMFileSystem(const WTF::PassRefPtr<DOMFileSystem>& domFileSystem) + : m_private(domFileSystem) +{ +} + +WebDOMFileSystem& WebDOMFileSystem::operator=(const WTF::PassRefPtr<WebCore::DOMFileSystem>& domFileSystem) +{ + m_private = domFileSystem; + return *this; +} + +WebDOMFileSystem::operator WTF::PassRefPtr<WebCore::DOMFileSystem>() const +{ + return m_private.get(); +} + +} // namespace WebKit diff --git a/Source/web/WebDOMMessageEvent.cpp b/Source/web/WebDOMMessageEvent.cpp index 54802c2a8..452f70e5a 100644 --- a/Source/web/WebDOMMessageEvent.cpp +++ b/Source/web/WebDOMMessageEvent.cpp @@ -38,8 +38,7 @@ #include "core/dom/Document.h" #include "core/events/MessageEvent.h" #include "core/dom/MessagePort.h" -#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h" -#include "core/page/DOMWindow.h" +#include "core/frame/DOMWindow.h" #include "public/platform/WebString.h" using namespace WebCore; diff --git a/Source/web/WebDevToolsAgentImpl.cpp b/Source/web/WebDevToolsAgentImpl.cpp index 1d9bd96b0..263755690 100644 --- a/Source/web/WebDevToolsAgentImpl.cpp +++ b/Source/web/WebDevToolsAgentImpl.cpp @@ -34,11 +34,13 @@ #include "InspectorBackendDispatcher.h" #include "InspectorFrontend.h" #include "InspectorProtocolVersion.h" +#include "RuntimeEnabledFeatures.h" #include "WebDataSource.h" #include "WebDevToolsAgentClient.h" #include "WebFrameImpl.h" #include "WebInputEventConversion.h" #include "WebMemoryUsageInfo.h" +#include "WebSettings.h" #include "WebViewClient.h" #include "WebViewImpl.h" #include "bindings/v8/PageScriptDebugServer.h" @@ -49,16 +51,16 @@ #include "core/fetch/MemoryCache.h" #include "core/inspector/InjectedScriptHost.h" #include "core/inspector/InspectorController.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/PageGroup.h" -#include "core/platform/JSONValues.h" #include "core/platform/graphics/GraphicsContext.h" -#include "core/platform/network/ResourceError.h" #include "core/platform/network/ResourceRequest.h" #include "core/platform/network/ResourceResponse.h" #include "core/rendering/RenderView.h" +#include "platform/JSONValues.h" +#include "platform/network/ResourceError.h" #include "public/platform/Platform.h" #include "public/platform/WebRect.h" #include "public/platform/WebString.h" @@ -187,170 +189,6 @@ private: OwnPtr<WebDevToolsAgent::MessageDescriptor> m_descriptor; }; -class DeviceMetricsSupport { -public: - DeviceMetricsSupport(WebViewImpl* webView) - : m_webView(webView) - , m_fitWindow(false) - , m_originalZoomFactor(0) - { - } - - ~DeviceMetricsSupport() - { - restore(); - } - - void setDeviceMetrics(int width, int height, float textZoomFactor, bool fitWindow) - { - WebCore::FrameView* view = frameView(); - if (!view) - return; - - m_emulatedFrameSize = WebSize(width, height); - m_fitWindow = fitWindow; - m_originalZoomFactor = 0; - m_webView->setTextZoomFactor(textZoomFactor); - applySizeOverrideInternal(view, FitWindowAllowed); - autoZoomPageToFitWidth(&view->frame()); - - m_webView->sendResizeEventAndRepaint(); - } - - void autoZoomPageToFitWidthOnNavigation(Frame* frame) - { - FrameView* frameView = frame->view(); - applySizeOverrideInternal(frameView, FitWindowNotAllowed); - m_originalZoomFactor = 0; - applySizeOverrideInternal(frameView, FitWindowAllowed); - autoZoomPageToFitWidth(frame); - } - - void autoZoomPageToFitWidth(Frame* frame) - { - frame->setTextZoomFactor(m_webView->textZoomFactor()); - ensureOriginalZoomFactor(frame->view()); - Document* document = frame->document(); - float numerator = document->renderView() ? document->renderView()->viewWidth() : frame->view()->contentsWidth(); - float factor = m_originalZoomFactor * (numerator / m_emulatedFrameSize.width); - frame->setPageAndTextZoomFactors(factor, m_webView->textZoomFactor()); - document->styleResolverChanged(RecalcStyleImmediately); - document->updateLayout(); - } - - void webViewResized() - { - if (!m_fitWindow) - return; - - applySizeOverrideIfNecessary(); - autoZoomPageToFitWidth(m_webView->mainFrameImpl()->frame()); - } - - void applySizeOverrideIfNecessary() - { - FrameView* view = frameView(); - if (!view) - return; - - applySizeOverrideInternal(view, FitWindowAllowed); - } - -private: - enum FitWindowFlag { FitWindowAllowed, FitWindowNotAllowed }; - - void ensureOriginalZoomFactor(FrameView* frameView) - { - if (m_originalZoomFactor) - return; - - m_webView->setPageScaleFactor(1, WebPoint()); - m_webView->setZoomLevel(0); - WebSize scaledEmulatedSize = scaledEmulatedFrameSize(frameView); - double denominator = frameView->contentsWidth(); - if (!denominator) - denominator = 1; - m_originalZoomFactor = static_cast<double>(scaledEmulatedSize.width) / denominator; - } - - void restore() - { - WebCore::FrameView* view = frameView(); - if (!view) - return; - - m_webView->setZoomLevel(0); - m_webView->setTextZoomFactor(1); - view->setHorizontalScrollbarLock(false); - view->setVerticalScrollbarLock(false); - view->setScrollbarModes(ScrollbarAuto, ScrollbarAuto, false, false); - view->setFrameRect(IntRect(IntPoint(), IntSize(m_webView->size()))); - m_webView->sendResizeEventAndRepaint(); - } - - WebSize scaledEmulatedFrameSize(FrameView* frameView) - { - if (!m_fitWindow) - return m_emulatedFrameSize; - - WebSize scrollbarDimensions = forcedScrollbarDimensions(frameView); - - int overrideWidth = m_emulatedFrameSize.width; - int overrideHeight = m_emulatedFrameSize.height; - - WebSize webViewSize = m_webView->size(); - int availableViewWidth = max(webViewSize.width - scrollbarDimensions.width, 1); - int availableViewHeight = max(webViewSize.height - scrollbarDimensions.height, 1); - - double widthRatio = static_cast<double>(overrideWidth) / availableViewWidth; - double heightRatio = static_cast<double>(overrideHeight) / availableViewHeight; - double dimensionRatio = max(widthRatio, heightRatio); - overrideWidth = static_cast<int>(ceil(static_cast<double>(overrideWidth) / dimensionRatio)); - overrideHeight = static_cast<int>(ceil(static_cast<double>(overrideHeight) / dimensionRatio)); - - return WebSize(overrideWidth, overrideHeight); - } - - WebSize forcedScrollbarDimensions(FrameView* frameView) - { - frameView->setScrollbarModes(ScrollbarAlwaysOn, ScrollbarAlwaysOn, true, true); - - int verticalScrollbarWidth = 0; - int horizontalScrollbarHeight = 0; - if (Scrollbar* verticalBar = frameView->verticalScrollbar()) - verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0; - if (Scrollbar* horizontalBar = frameView->horizontalScrollbar()) - horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0; - return WebSize(verticalScrollbarWidth, horizontalScrollbarHeight); - } - - void applySizeOverrideInternal(FrameView* frameView, FitWindowFlag fitWindowFlag) - { - WebSize scrollbarDimensions = forcedScrollbarDimensions(frameView); - - WebSize effectiveEmulatedSize = (fitWindowFlag == FitWindowAllowed) ? scaledEmulatedFrameSize(frameView) : m_emulatedFrameSize; - int overrideWidth = effectiveEmulatedSize.width + scrollbarDimensions.width; - int overrideHeight = effectiveEmulatedSize.height + scrollbarDimensions.height; - - if (IntSize(overrideWidth, overrideHeight) != frameView->size()) - frameView->resize(overrideWidth, overrideHeight); - - Document* doc = frameView->frame().document(); - doc->styleResolverChanged(RecalcStyleImmediately); - doc->updateLayout(); - } - - WebCore::FrameView* frameView() - { - return m_webView->mainFrameImpl() ? m_webView->mainFrameImpl()->frameView() : 0; - } - - WebViewImpl* m_webView; - WebSize m_emulatedFrameSize; - bool m_fitWindow; - double m_originalZoomFactor; -}; - WebDevToolsAgentImpl::WebDevToolsAgentImpl( WebViewImpl* webViewImpl, WebDevToolsAgentClient* client) @@ -358,6 +196,9 @@ WebDevToolsAgentImpl::WebDevToolsAgentImpl( , m_client(client) , m_webViewImpl(webViewImpl) , m_attached(false) + , m_generatingEvent(false) + , m_deviceMetricsEnabled(false) + , m_isOverlayScrollbarsEnabled(false) { ASSERT(m_hostId > 0); ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); @@ -440,28 +281,15 @@ void WebDevToolsAgentImpl::didCreateScriptContext(WebFrameImpl* webframe, int wo frame->script()->setContextDebugId(m_hostId); } -void WebDevToolsAgentImpl::mainFrameViewCreated(WebFrameImpl* webFrame) -{ - if (m_metricsSupport) - m_metricsSupport->applySizeOverrideIfNecessary(); -} - -bool WebDevToolsAgentImpl::metricsOverridden() -{ - return !!m_metricsSupport; -} - void WebDevToolsAgentImpl::webViewResized(const WebSize& size) { - if (m_metricsSupport) - m_metricsSupport->webViewResized(); if (InspectorController* ic = inspectorController()) - ic->webViewResized(m_metricsSupport ? IntSize(size.width, size.height) : IntSize()); + ic->webViewResized(IntSize()); } bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputEvent& inputEvent) { - if (!m_attached) + if (!m_attached && !m_generatingEvent) return false; InspectorController* ic = inspectorController(); @@ -485,32 +313,24 @@ bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputE return false; } -void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow) +void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool fitWindow) { if (!width && !height) { - if (m_metricsSupport) - m_metricsSupport.clear(); - if (InspectorController* ic = inspectorController()) - ic->webViewResized(IntSize()); - return; - } - - if (!m_metricsSupport) - m_metricsSupport = adoptPtr(new DeviceMetricsSupport(m_webViewImpl)); - - m_metricsSupport->setDeviceMetrics(width, height, fontScaleFactor, fitWindow); - if (InspectorController* ic = inspectorController()) { - WebSize size = m_webViewImpl->size(); - ic->webViewResized(IntSize(size.width, size.height)); + if (m_deviceMetricsEnabled) { + RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrollbarsEnabled); + m_client->disableDeviceEmulation(); + } + m_deviceMetricsEnabled = false; + } else { + if (!m_deviceMetricsEnabled) { + m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnabled(); + RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); + } + m_client->enableDeviceEmulation(IntSize(width, height), IntRect(0, 0, width, height), deviceScaleFactor, fitWindow); + m_deviceMetricsEnabled = true; } } -void WebDevToolsAgentImpl::autoZoomPageToFitWidth() -{ - if (m_metricsSupport) - m_metricsSupport->autoZoomPageToFitWidthOnNavigation(m_webViewImpl->mainFrameImpl()->frame()); -} - void WebDevToolsAgentImpl::getAllocatedObjects(HashSet<const void*>& set) { class CountingVisitor : public WebDevToolsAgentClient::AllocatedObjectVisitor { @@ -614,16 +434,20 @@ void WebDevToolsAgentImpl::setTraceEventCallback(TraceEventCallback callback) void WebDevToolsAgentImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event) { + m_generatingEvent = true; WebKeyboardEvent webEvent = WebKeyboardEventBuilder(event); if (!webEvent.keyIdentifier[0] && webEvent.type != WebInputEvent::Char) webEvent.setKeyIdentifierFromWindowsKeyCode(); m_webViewImpl->handleInputEvent(webEvent); + m_generatingEvent = false; } void WebDevToolsAgentImpl::dispatchMouseEvent(const PlatformMouseEvent& event) { + m_generatingEvent = true; WebMouseEvent webEvent = WebMouseEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), event); m_webViewImpl->handleInputEvent(webEvent); + m_generatingEvent = false; } void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message) diff --git a/Source/web/WebDevToolsAgentImpl.h b/Source/web/WebDevToolsAgentImpl.h index afa0b9f34..23c2044b2 100644 --- a/Source/web/WebDevToolsAgentImpl.h +++ b/Source/web/WebDevToolsAgentImpl.h @@ -54,7 +54,6 @@ class PlatformKeyboardEvent; namespace WebKit { -class DeviceMetricsSupport; class WebDevToolsAgentClient; class WebFrame; class WebFrameImpl; @@ -77,8 +76,6 @@ public: // WebDevToolsAgentPrivate implementation. virtual void didCreateScriptContext(WebFrameImpl*, int worldId); - virtual void mainFrameViewCreated(WebFrameImpl*); - virtual bool metricsOverridden(); virtual void webViewResized(const WebSize&); virtual bool handleInputEvent(WebCore::Page*, const WebInputEvent&); @@ -106,8 +103,7 @@ public: virtual void clearBrowserCache(); virtual void clearBrowserCookies(); - virtual void overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow); - virtual void autoZoomPageToFitWidth(); + virtual void overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool fitWindow); virtual void getAllocatedObjects(HashSet<const void*>&); virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&); @@ -133,7 +129,9 @@ private: WebDevToolsAgentClient* m_client; WebViewImpl* m_webViewImpl; bool m_attached; - OwnPtr<DeviceMetricsSupport> m_metricsSupport; + bool m_generatingEvent; + bool m_deviceMetricsEnabled; + bool m_isOverlayScrollbarsEnabled; }; } // namespace WebKit diff --git a/Source/web/WebDevToolsAgentPrivate.h b/Source/web/WebDevToolsAgentPrivate.h index 2c57e0f6d..87333fee6 100644 --- a/Source/web/WebDevToolsAgentPrivate.h +++ b/Source/web/WebDevToolsAgentPrivate.h @@ -47,13 +47,6 @@ public: // in this context should be done here. virtual void didCreateScriptContext(WebFrameImpl*, int worldId) = 0; - // A new FrameView has been created for the specified WebFrame using - // the Frame::createView() call. - virtual void mainFrameViewCreated(WebFrameImpl*) = 0; - - // Returns true if the device metrics override mode is enabled. - virtual bool metricsOverridden() = 0; - // WebViewImpl has been resized. virtual void webViewResized(const WebSize&) = 0; diff --git a/Source/web/WebDevToolsFrontendImpl.cpp b/Source/web/WebDevToolsFrontendImpl.cpp index 611d4db49..3e1241a2a 100644 --- a/Source/web/WebDevToolsFrontendImpl.cpp +++ b/Source/web/WebDevToolsFrontendImpl.cpp @@ -49,8 +49,8 @@ #include "core/inspector/InspectorController.h" #include "core/inspector/InspectorFrontendHost.h" #include "core/page/ContextMenuController.h" -#include "core/page/DOMWindow.h" -#include "core/page/Frame.h" +#include "core/frame/DOMWindow.h" +#include "core/frame/Frame.h" #include "core/page/Page.h" #include "core/page/Settings.h" #include "core/platform/ContextMenuItem.h" @@ -75,11 +75,6 @@ public: } private: - virtual bool canSuspend() const OVERRIDE - { - return true; - } - virtual void resume() OVERRIDE { m_webDevToolsFrontendImpl->resume(); @@ -125,7 +120,7 @@ void WebDevToolsFrontendImpl::dispatchOnInspectorFrontend(const WebString& messa void WebDevToolsFrontendImpl::resume() { // We should call maybeDispatch asynchronously here because we are not allowed to update activeDOMObjects list in - // resume (See ScriptExecutionContext::resumeActiveDOMObjects). + // resume (See ExecutionContext::resumeActiveDOMObjects). if (!m_inspectorFrontendDispatchTimer.isActive()) m_inspectorFrontendDispatchTimer.startOneShot(0); } @@ -174,7 +169,7 @@ void WebDevToolsFrontendImpl::doDispatchOnInspectorFrontend(const WebString& mes args.append(v8String(message, isolate)); v8::TryCatch tryCatch; tryCatch.SetVerbose(true); - ScriptController::callFunctionWithInstrumentation(frame->frame() ? frame->frame()->document() : 0, function, dispatcherObject, args.size(), args.data(), isolate); + ScriptController::callFunction(frame->frame()->document(), function, dispatcherObject, args.size(), args.data(), isolate); } } // namespace WebKit diff --git a/Source/web/WebDevToolsFrontendImpl.h b/Source/web/WebDevToolsFrontendImpl.h index 31a8742c4..d8dbad11f 100644 --- a/Source/web/WebDevToolsFrontendImpl.h +++ b/Source/web/WebDevToolsFrontendImpl.h @@ -32,7 +32,7 @@ #define WebDevToolsFrontendImpl_h #include "WebDevToolsFrontend.h" -#include "core/platform/Timer.h" +#include "platform/Timer.h" #include "wtf/Deque.h" #include "wtf/Forward.h" #include "wtf/Noncopyable.h" diff --git a/Source/web/WebDeviceOrientation.cpp b/Source/web/WebDeviceOrientation.cpp deleted file mode 100644 index 2b850e2ca..000000000 --- a/Source/web/WebDeviceOrientation.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WebDeviceOrientation.h" - -#include "modules/device_orientation/DeviceOrientationData.h" -#include "wtf/PassRefPtr.h" - -namespace WebKit { - -WebDeviceOrientation::WebDeviceOrientation(const WebCore::DeviceOrientationData* orientation) -{ - if (!orientation) { - m_isNull = true; - m_canProvideAlpha = false; - m_alpha = 0; - m_canProvideBeta = false; - m_beta = 0; - m_canProvideGamma = false; - m_gamma = 0; - m_canProvideAbsolute = false; - m_absolute = false; - return; - } - - m_isNull = false; - m_canProvideAlpha = orientation->canProvideAlpha(); - m_alpha = orientation->alpha(); - m_canProvideBeta = orientation->canProvideBeta(); - m_beta = orientation->beta(); - m_canProvideGamma = orientation->canProvideGamma(); - m_gamma = orientation->gamma(); - m_canProvideAbsolute = orientation->canProvideAbsolute(); - m_absolute = orientation->absolute(); -} - -WebDeviceOrientation::operator PassRefPtr<WebCore::DeviceOrientationData>() const -{ - if (m_isNull) - return 0; - return WebCore::DeviceOrientationData::create(m_canProvideAlpha, m_alpha, m_canProvideBeta, m_beta, m_canProvideGamma, m_gamma, m_canProvideAbsolute, m_absolute); -} - -} // namespace WebKit diff --git a/Source/web/WebDeviceOrientationClientMock.cpp b/Source/web/WebDeviceOrientationClientMock.cpp deleted file mode 100644 index c64f16e6c..000000000 --- a/Source/web/WebDeviceOrientationClientMock.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WebDeviceOrientationClientMock.h" - -#include "WebDeviceOrientation.h" -#include "WebDeviceOrientationController.h" -#include "core/platform/mock/DeviceOrientationClientMock.h" - -namespace WebKit { - -WebDeviceOrientationClientMock* WebDeviceOrientationClientMock::create() -{ - return new WebDeviceOrientationClientMock(); -} - -void WebDeviceOrientationClientMock::setController(WebDeviceOrientationController* controller) -{ - m_clientMock->setController(controller->controller()); - delete controller; -} - -void WebDeviceOrientationClientMock::startUpdating() -{ - m_clientMock->startUpdating(); -} - -void WebDeviceOrientationClientMock::stopUpdating() -{ - m_clientMock->stopUpdating(); -} - -WebDeviceOrientation WebDeviceOrientationClientMock::lastOrientation() const -{ - return WebDeviceOrientation(m_clientMock->lastOrientation()); -} - -void WebDeviceOrientationClientMock::setOrientation(WebDeviceOrientation& orientation) -{ - m_clientMock->setOrientation(orientation); -} - -void WebDeviceOrientationClientMock::initialize() -{ - m_clientMock.reset(new WebCore::DeviceOrientationClientMock()); -} - -void WebDeviceOrientationClientMock::reset() -{ - m_clientMock.reset(0); -} - -} // namespace WebKit diff --git a/Source/web/WebDeviceOrientationController.cpp b/Source/web/WebDeviceOrientationController.cpp deleted file mode 100644 index 007b0c288..000000000 --- a/Source/web/WebDeviceOrientationController.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WebDeviceOrientationController.h" - -#include "WebDeviceOrientation.h" -#include "core/dom/DeviceOrientationController.h" -#include "modules/device_orientation/DeviceOrientationData.h" -#include "wtf/PassRefPtr.h" - -namespace WebKit { - -void WebDeviceOrientationController::didChangeDeviceOrientation(const WebDeviceOrientation& orientation) -{ - RefPtr<WebCore::DeviceOrientationData> deviceOrientation = PassRefPtr<WebCore::DeviceOrientationData>(orientation); - m_controller->didChangeDeviceOrientation(deviceOrientation.get()); -} - -WebCore::DeviceOrientationController* WebDeviceOrientationController::controller() const -{ - return m_controller; -} - -} // namespace WebKit diff --git a/Source/web/WebDocument.cpp b/Source/web/WebDocument.cpp index 4e55b5fb1..51046f7c2 100644 --- a/Source/web/WebDocument.cpp +++ b/Source/web/WebDocument.cpp @@ -46,6 +46,7 @@ #include "core/accessibility/AXObjectCache.h" #include "core/css/CSSParserMode.h" #include "core/css/StyleSheetContents.h" +#include "core/dom/CSSSelectorWatch.h" #include "core/dom/Document.h" #include "core/dom/DocumentType.h" #include "core/dom/Element.h" @@ -213,6 +214,14 @@ void WebDocument::insertUserStyleSheet(const WebString& sourceCode, UserStyleLev document->styleEngine()->addAuthorSheet(parsedSheet); } +void WebDocument::watchCSSSelectors(const WebVector<WebString>& webSelectors) +{ + RefPtr<Document> document = unwrap<Document>(); + Vector<String> selectors; + selectors.append(webSelectors.data(), webSelectors.size()); + CSSSelectorWatch::from(*document).watchCSSSelectors(selectors); +} + void WebDocument::cancelFullScreen() { if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(unwrap<Document>())) diff --git a/Source/web/WebDragData.cpp b/Source/web/WebDragData.cpp index 4b3f77051..78ea502fa 100644 --- a/Source/web/WebDragData.cpp +++ b/Source/web/WebDragData.cpp @@ -32,8 +32,8 @@ #include "core/dom/DataTransferItem.h" #include "core/platform/chromium/ChromiumDataObject.h" -#include "core/platform/chromium/ClipboardMimeTypes.h" #include "modules/filesystem/DraggedIsolatedFileSystem.h" +#include "platform/clipboard/ClipboardMimeTypes.h" #include "public/platform/WebData.h" #include "public/platform/WebDragData.h" #include "public/platform/WebString.h" diff --git a/Source/web/WebElement.cpp b/Source/web/WebElement.cpp index d52434081..59b841803 100644 --- a/Source/web/WebElement.cpp +++ b/Source/web/WebElement.cpp @@ -32,9 +32,9 @@ #include "WebDocument.h" #include "WebElement.h" #include "bindings/v8/ExceptionState.h" -#include "core/dom/CustomElementCallbackDispatcher.h" #include "core/dom/Element.h" #include "core/dom/NamedNodeMap.h" +#include "core/dom/custom/CustomElementCallbackDispatcher.h" #include "core/dom/shadow/ShadowRoot.h" #include "core/rendering/RenderBoxModelObject.h" #include "core/rendering/RenderObject.h" diff --git a/Source/web/WebFileChooserCompletionImpl.h b/Source/web/WebFileChooserCompletionImpl.h index a464f0b3a..f025a5ef2 100644 --- a/Source/web/WebFileChooserCompletionImpl.h +++ b/Source/web/WebFileChooserCompletionImpl.h @@ -32,7 +32,7 @@ #define WebFileChooserCompletionImpl_h #include "WebFileChooserCompletion.h" -#include "core/platform/FileChooser.h" +#include "platform/FileChooser.h" #include "public/platform/WebString.h" #include "public/platform/WebVector.h" #include "wtf/PassRefPtr.h" diff --git a/Source/web/WebFontImpl.cpp b/Source/web/WebFontImpl.cpp index cc04c69c5..2de9babb9 100644 --- a/Source/web/WebFontImpl.cpp +++ b/Source/web/WebFontImpl.cpp @@ -38,7 +38,7 @@ #include "core/platform/graphics/FontCache.h" #include "core/platform/graphics/FontDescription.h" #include "core/platform/graphics/GraphicsContext.h" -#include "core/platform/graphics/TextRun.h" +#include "platform/graphics/TextRun.h" #include "public/platform/WebFloatPoint.h" #include "public/platform/WebFloatRect.h" #include "public/platform/WebRect.h" diff --git a/Source/web/WebFormControlElement.cpp b/Source/web/WebFormControlElement.cpp index bbaa64797..bd929fed4 100644 --- a/Source/web/WebFormControlElement.cpp +++ b/Source/web/WebFormControlElement.cpp @@ -64,6 +64,16 @@ void WebFormControlElement::dispatchFormControlChangeEvent() unwrap<HTMLFormControlElement>()->dispatchFormControlChangeEvent(); } +bool WebFormControlElement::isAutofilled() const +{ + return constUnwrap<HTMLFormControlElement>()->isAutofilled(); +} + +void WebFormControlElement::setAutofilled(bool autofilled) +{ + unwrap<HTMLFormControlElement>()->setAutofilled(autofilled); +} + WebString WebFormControlElement::nameForAutofill() const { String name = constUnwrap<HTMLFormControlElement>()->name(); diff --git a/Source/web/WebFormElement.cpp b/Source/web/WebFormElement.cpp index c0ce7a289..01de30fac 100644 --- a/Source/web/WebFormElement.cpp +++ b/Source/web/WebFormElement.cpp @@ -87,19 +87,14 @@ void WebFormElement::getNamedElements(const WebString& name, void WebFormElement::getFormControlElements(WebVector<WebFormControlElement>& result) const { const HTMLFormElement* form = constUnwrap<HTMLFormElement>(); - Vector<RefPtr<HTMLFormControlElement> > tempVector; - // FIXME: We should move the for-loop condition into a variable instead of - // re-evaluating size each time. Also, consider refactoring this code so that - // we don't call form->associatedElements() multiple times. - for (size_t i = 0; i < form->associatedElements().size(); i++) { - if (!form->associatedElements()[i]->isFormControlElement()) - continue; - HTMLFormControlElement* element = toHTMLFormControlElement(form->associatedElements()[i]); - if (element->hasLocalName(HTMLNames::inputTag) - || element->hasLocalName(HTMLNames::selectTag)) - tempVector.append(element); + Vector<RefPtr<HTMLFormControlElement> > formControlElements; + + const Vector<FormAssociatedElement*>& associatedElements = form->associatedElements(); + for (Vector<FormAssociatedElement*>::const_iterator it = associatedElements.begin(); it != associatedElements.end(); ++it) { + if ((*it)->isFormControlElement()) + formControlElements.append(toHTMLFormControlElement(*it)); } - result.assign(tempVector); + result.assign(formControlElements); } bool WebFormElement::checkValidityWithoutDispatchingEvents() diff --git a/Source/web/WebFrameImpl.cpp b/Source/web/WebFrameImpl.cpp index 5a53a30f4..d160e3676 100644 --- a/Source/web/WebFrameImpl.cpp +++ b/Source/web/WebFrameImpl.cpp @@ -50,7 +50,7 @@ // ref initially and it is removed when the FrameLoader is getting destroyed. // // WebFrames are created in two places, first in WebViewImpl when the root -// frame is created, and second in WebFrame::CreateChildFrame when sub-frames +// frame is created, and second in WebFrame::createChildFrame when sub-frames // are created. WebKit will hook up this object to the FrameLoader/Frame // and the refcount will be correct. // @@ -64,13 +64,17 @@ // in FrameLoader::detachFromParent for each subframe. // // Frame going away causes the FrameLoader to get deleted. In FrameLoader's -// destructor, it notifies its client with frameLoaderDestroyed. This calls -// WebFrame::Closing and then derefs the WebFrame and will cause it to be -// deleted (unless an external someone is also holding a reference). +// destructor, it notifies its client with frameLoaderDestroyed. This derefs +// the WebFrame and will cause it to be deleted (unless an external someone +// is also holding a reference). +// +// Thie client is expected to be set whenever the WebFrameImpl is attached to +// the DOM. #include "config.h" #include "WebFrameImpl.h" +#include <algorithm> #include "AssociatedURLLoader.h" #include "DOMUtilitiesPrivate.h" #include "EventListenerWrapper.h" @@ -116,17 +120,16 @@ #include "core/dom/MessagePort.h" #include "core/dom/Node.h" #include "core/dom/NodeTraversal.h" -#include "core/dom/UserGestureIndicator.h" -#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h" #include "core/dom/shadow/ShadowRoot.h" #include "core/editing/Editor.h" #include "core/editing/FrameSelection.h" #include "core/editing/InputMethodController.h" -#include "core/editing/SpellCheckRequester.h" +#include "core/editing/SpellChecker.h" #include "core/editing/TextAffinity.h" #include "core/editing/TextIterator.h" #include "core/editing/htmlediting.h" #include "core/editing/markup.h" +#include "core/frame/Console.h" #include "core/history/BackForwardController.h" #include "core/history/HistoryItem.h" #include "core/html/HTMLCollection.h" @@ -146,20 +149,15 @@ #include "core/loader/IconController.h" #include "core/loader/SubstituteData.h" #include "core/page/Chrome.h" -#include "core/page/Console.h" -#include "core/page/DOMWindow.h" +#include "core/frame/DOMWindow.h" #include "core/page/EventHandler.h" #include "core/page/FocusController.h" #include "core/page/FrameTree.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" -#include "core/page/Performance.h" #include "core/page/PrintContext.h" #include "core/page/Settings.h" -#include "core/platform/ScrollTypes.h" #include "core/platform/ScrollbarTheme.h" -#include "core/platform/chromium/ClipboardUtilitiesChromium.h" -#include "core/platform/chromium/TraceEvent.h" #include "core/platform/graphics/FontCache.h" #include "core/platform/graphics/GraphicsContext.h" #include "core/platform/graphics/GraphicsLayerClient.h" @@ -173,12 +171,17 @@ #include "core/rendering/RenderTreeAsText.h" #include "core/rendering/RenderView.h" #include "core/rendering/style/StyleInheritedData.h" +#include "core/timing/Performance.h" #include "core/xml/DocumentXPathEvaluator.h" #include "core/xml/XPathResult.h" #include "modules/filesystem/DOMFileSystem.h" #include "modules/filesystem/DirectoryEntry.h" #include "modules/filesystem/FileEntry.h" -#include "modules/filesystem/FileSystemType.h" +#include "platform/FileSystemType.h" +#include "platform/TraceEvent.h" +#include "platform/UserGestureIndicator.h" +#include "platform/clipboard/ClipboardUtilities.h" +#include "platform/scroll/ScrollTypes.h" #include "public/platform/Platform.h" #include "public/platform/WebFileSystem.h" #include "public/platform/WebFileSystemType.h" @@ -194,7 +197,6 @@ #include "weborigin/SecurityPolicy.h" #include "wtf/CurrentTime.h" #include "wtf/HashMap.h" -#include <algorithm> using namespace WebCore; @@ -266,12 +268,6 @@ static void frameContentAsPlainText(size_t maxChars, Frame* frame, StringBuilder } } -static long long generateFrameIdentifier() -{ - static long long next = 0; - return ++next; -} - WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(Frame* frame) { if (!frame) @@ -526,6 +522,12 @@ WebFrame* WebFrame::fromFrameOwnerElement(const WebElement& element) return WebFrameImpl::fromFrameOwnerElement(PassRefPtr<Element>(element).get()); } +void WebFrameImpl::close() +{ + m_client = 0; + deref(); // Balances ref() acquired in WebFrame::create +} + WebString WebFrameImpl::uniqueName() const { return frame()->tree()->uniqueName(); @@ -541,9 +543,9 @@ void WebFrameImpl::setName(const WebString& name) frame()->tree()->setName(name); } -long long WebFrameImpl::identifier() const +long long WebFrameImpl::embedderIdentifier() const { - return m_identifier; + return m_embedderIdentifier; } WebVector<WebIconURL> WebFrameImpl::iconURLs(int iconTypesMask) const @@ -744,7 +746,7 @@ void WebFrameImpl::executeScript(const WebScriptSource& source) { ASSERT(frame()); TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), OrdinalNumber::first()); - frame()->script()->executeScript(ScriptSourceCode(source.code, source.url, position)); + frame()->script()->executeScriptInMainWorld(ScriptSourceCode(source.code, source.url, position)); } void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup) @@ -826,7 +828,7 @@ v8::Handle<v8::Value> WebFrameImpl::executeScriptAndReturnValue(const WebScriptS UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), OrdinalNumber::first()); - return frame()->script()->executeScript(ScriptSourceCode(source.code, source.url, position)).v8Value(); + return frame()->script()->executeScriptInMainWorldAndReturnValue(ScriptSourceCode(source.code, source.url, position)).v8Value(); } void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::Value> >* results) @@ -856,7 +858,7 @@ void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour v8::Handle<v8::Value> WebFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[]) { ASSERT(frame()); - return frame()->script()->callFunctionEvenIfScriptDisabled(function, receiver, argc, argv).v8Value(); + return frame()->script()->callFunction(function, receiver, argc, argv); } v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const @@ -1168,9 +1170,9 @@ bool WebFrameImpl::executeCommand(const WebString& name, const WebNode& node) result = frame()->editor().command(AtomicString("ForwardDelete")).execute(); } else if (command == "AdvanceToNextMisspelling") { // Wee need to pass false here or else the currently selected word will never be skipped. - frame()->editor().advanceToNextMisspelling(false); + frame()->spellChecker().advanceToNextMisspelling(false); } else if (command == "ToggleSpellPanel") { - frame()->editor().showSpellingGuessPanel(); + frame()->spellChecker().showSpellingGuessPanel(); } else { result = frame()->editor().command(command).execute(); } @@ -1193,6 +1195,11 @@ bool WebFrameImpl::executeCommand(const WebString& name, const WebString& value, if (!frame()->editor().canEdit() && webName == "moveToEndOfDocument") return viewImpl()->propagateScroll(ScrollDown, ScrollByDocument); + if (webName == "showGuessPanel") { + frame()->spellChecker().showSpellingGuessPanel(); + return true; + } + return frame()->editor().command(webName).execute(value); } @@ -1206,20 +1213,19 @@ void WebFrameImpl::enableContinuousSpellChecking(bool enable) { if (enable == isContinuousSpellCheckingEnabled()) return; - frame()->editor().toggleContinuousSpellChecking(); + frame()->spellChecker().toggleContinuousSpellChecking(); } bool WebFrameImpl::isContinuousSpellCheckingEnabled() const { - return frame()->editor().isContinuousSpellCheckingEnabled(); + return frame()->spellChecker().isContinuousSpellCheckingEnabled(); } void WebFrameImpl::requestTextChecking(const WebElement& webElement) { if (webElement.isNull()) return; - RefPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*>(webElement.constUnwrap<Element>())); - frame()->editor().spellCheckRequester().requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToCheck, rangeToCheck)); + frame()->spellChecker().requestTextChecking(*webElement.constUnwrap<Element>()); } void WebFrameImpl::replaceMisspelledRange(const WebString& text) @@ -1236,8 +1242,6 @@ void WebFrameImpl::replaceMisspelledRange(const WebString& text) RefPtr<Range> markerRange = Range::create(caretRange->ownerDocument(), caretRange->startContainer(), markers[0]->startOffset(), caretRange->endContainer(), markers[0]->endOffset()); if (!markerRange) return; - if (!frame()->selection().shouldChangeSelection(markerRange.get())) - return; frame()->selection().setSelection(markerRange.get(), CharacterGranularity); frame()->editor().replaceSelectionWithText(text, false, false); } @@ -1298,10 +1302,8 @@ void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition positi VisibleSelection selection(position); selection.expandUsingGranularity(WordGranularity); - if (frame->selection().shouldChangeSelection(selection)) { - TextGranularity granularity = selection.isRange() ? WordGranularity : CharacterGranularity; - frame->selection().setSelection(selection, granularity); - } + TextGranularity granularity = selection.isRange() ? WordGranularity : CharacterGranularity; + frame->selection().setSelection(selection, granularity); } bool WebFrameImpl::selectWordAroundCaret() @@ -1335,8 +1337,7 @@ void WebFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& exte VisiblePosition basePosition = visiblePositionForWindowPoint(base); VisiblePosition extentPosition = visiblePositionForWindowPoint(extent); VisibleSelection newSelection = VisibleSelection(basePosition, extentPosition); - if (frame()->selection().shouldChangeSelection(newSelection)) - frame()->selection().setSelection(newSelection, CharacterGranularity); + frame()->selection().setSelection(newSelection, CharacterGranularity); } void WebFrameImpl::moveCaretSelection(const WebPoint& point) @@ -1346,8 +1347,7 @@ void WebFrameImpl::moveCaretSelection(const WebPoint& point) return; VisiblePosition position = visiblePositionForWindowPoint(point); - if (frame()->selection().shouldChangeSelection(position)) - frame()->selection().moveTo(position, UserTriggered); + frame()->selection().moveTo(position, UserTriggered); } void WebFrameImpl::setCaretVisible(bool visible) @@ -2048,7 +2048,7 @@ bool WebFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) cons { if (!frame()) return false; - return frame()->editor().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); + return frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); } WebString WebFrameImpl::layerTreeAsText(bool showDebugInfo) const @@ -2061,12 +2061,34 @@ WebString WebFrameImpl::layerTreeAsText(bool showDebugInfo) const // WebFrameImpl public --------------------------------------------------------- -PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client) +WebFrame* WebFrame::create(WebFrameClient* client) { - return adoptRef(new WebFrameImpl(client)); + return WebFrameImpl::create(client); } -WebFrameImpl::WebFrameImpl(WebFrameClient* client) +WebFrame* WebFrame::create(WebFrameClient* client, long long embedderIdentifier) +{ + return WebFrameImpl::create(client, embedderIdentifier); +} + +long long WebFrame::generateEmbedderIdentifier() +{ + static long long next = 0; + // Assume that 64-bit will not wrap to -1. + return ++next; +} + +WebFrameImpl* WebFrameImpl::create(WebFrameClient* client) +{ + return WebFrameImpl::create(client, generateEmbedderIdentifier()); +} + +WebFrameImpl* WebFrameImpl::create(WebFrameClient* client, long long embedderIdentifier) +{ + return adoptRef(new WebFrameImpl(client, embedderIdentifier)).leakRef(); +} + +WebFrameImpl::WebFrameImpl(WebFrameClient* client, long long embedderIdentifier) : FrameDestructionObserver(0) , m_frameLoaderClient(this) , m_client(client) @@ -2083,8 +2105,9 @@ WebFrameImpl::WebFrameImpl(WebFrameClient* client) , m_nextInvalidateAfter(0) , m_findMatchMarkersVersion(0) , m_findMatchRectsAreValid(false) - , m_identifier(generateFrameIdentifier()) + , m_embedderIdentifier(embedderIdentifier) , m_inSameDocumentHistoryLoad(false) + , m_inputEventsScaleFactorForEmulation(1) { WebKit::Platform::current()->incrementStatsCounter(webFrameActiveCount); frameCount++; @@ -2109,7 +2132,7 @@ void WebFrameImpl::initializeAsMainFrame(WebCore::Page* page) RefPtr<Frame> mainFrame = Frame::create(page, 0, &m_frameLoaderClient); setWebCoreFrame(mainFrame.get()); - // Add reference on behalf of FrameLoader. See comments in + // Add reference on behalf of FrameLoader. See comments in // WebFrameLoaderClient::frameLoaderDestroyed for more info. ref(); @@ -2120,9 +2143,26 @@ void WebFrameImpl::initializeAsMainFrame(WebCore::Page* page) PassRefPtr<Frame> WebFrameImpl::createChildFrame(const FrameLoadRequest& request, HTMLFrameOwnerElement* ownerElement) { - RefPtr<WebFrameImpl> webframe(adoptRef(new WebFrameImpl(m_client))); + ASSERT(m_client); + WebFrameImpl* webframe = toWebFrameImpl(m_client->createChildFrame(this, request.frameName())); + + // If the embedder is returning 0 from createChildFrame(), it has not been + // updated to the new ownership semantics where the embedder creates the + // WebFrame. In that case, fall back to the old logic where the + // WebFrameImpl is created here and published back to the embedder. To + // bridge between the two ownership semantics, webframeLifetimeHack is + // needeed to balance out the refcounting. + // + // FIXME: Remove once all embedders return non-null from createChildFrame(). + RefPtr<WebFrameImpl> webframeLifetimeHack; + bool mustCallDidCreateFrame = false; + if (!webframe) { + mustCallDidCreateFrame = true; + webframeLifetimeHack = adoptRef(WebFrameImpl::create(m_client)); + webframe = webframeLifetimeHack.get(); + } - // Add an extra ref on behalf of the Frame/FrameLoader, which references the + // Add an extra ref on behalf of the page/FrameLoader, which references the // WebFrame via the FrameLoaderClient interface. See the comment at the top // of this file for more info. webframe->ref(); @@ -2134,6 +2174,10 @@ PassRefPtr<Frame> WebFrameImpl::createChildFrame(const FrameLoadRequest& request frame()->tree()->appendChild(childFrame); + // FIXME: Remove once all embedders return non-null from createChildFrame(). + if (mustCallDidCreateFrame) + m_client->didCreateFrame(this, webframe); + // Frame::init() can trigger onload event in the parent frame, // which may detach this frame and trigger a null-pointer access // in FrameTree::removeChild. Move init() after appendChild call @@ -2142,6 +2186,7 @@ PassRefPtr<Frame> WebFrameImpl::createChildFrame(const FrameLoadRequest& request // Because the event handler may set webframe->mFrame to null, // it is necessary to check the value after calling init() and // return without loading URL. + // NOTE: m_client will be null if this frame has been detached. // (b:791612) childFrame->init(); // create an empty document if (!childFrame->tree()->parent()) @@ -2162,12 +2207,10 @@ PassRefPtr<Frame> WebFrameImpl::createChildFrame(const FrameLoadRequest& request // A synchronous navigation (about:blank) would have already processed // onload, so it is possible for the frame to have already been destroyed by // script in the page. + // NOTE: m_client will be null if this frame has been detached. if (!childFrame->tree()->parent()) return 0; - if (m_client) - m_client->didCreateFrame(this, webframe.get()); - return childFrame.release(); } @@ -2195,18 +2238,17 @@ void WebFrameImpl::createFrameView() if (webView->shouldAutoResize() && isMainFrame) frame()->view()->enableAutoSizeMode(true, webView->minAutoSize(), webView->maxAutoSize()); + frame()->view()->setInputEventsScaleFactorForEmulation(m_inputEventsScaleFactorForEmulation); + if (isMainFrame) webView->suppressInvalidations(false); - - if (isMainFrame && webView->devToolsAgentPrivate()) - webView->devToolsAgentPrivate()->mainFrameViewCreated(this); } WebFrameImpl* WebFrameImpl::fromFrame(Frame* frame) { if (!frame) return 0; - return static_cast<FrameLoaderClientImpl*>(frame->loader()->client())->webFrame(); + return toFrameLoaderClientImpl(frame->loader()->client())->webFrame(); } WebFrameImpl* WebFrameImpl::fromFrameOwnerElement(Element* element) @@ -2314,6 +2356,13 @@ void WebFrameImpl::setCanHaveScrollbars(bool canHaveScrollbars) frame()->view()->setCanHaveScrollbars(canHaveScrollbars); } +void WebFrameImpl::setInputEventsScaleFactorForEmulation(float contentScaleFactor) +{ + m_inputEventsScaleFactorForEmulation = contentScaleFactor; + if (frame()->view()) + frame()->view()->setInputEventsScaleFactorForEmulation(m_inputEventsScaleFactorForEmulation); +} + void WebFrameImpl::invalidateArea(AreaToInvalidate area) { ASSERT(frame() && frame()->view()); @@ -2443,7 +2492,8 @@ void WebFrameImpl::loadJavaScriptURL(const KURL& url) return; String script = decodeURLEscapeSequences(url.string().substring(strlen("javascript:"))); - ScriptValue result = frame()->script()->executeScript(script, true); + UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); + ScriptValue result = frame()->script()->executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script)); String scriptResult; if (!result.getString(scriptResult)) diff --git a/Source/web/WebFrameImpl.h b/Source/web/WebFrameImpl.h index 18696db49..37b667bb5 100644 --- a/Source/web/WebFrameImpl.h +++ b/Source/web/WebFrameImpl.h @@ -34,9 +34,9 @@ #include "WebFrame.h" #include "FrameLoaderClientImpl.h" -#include "core/page/Frame.h" -#include "core/page/FrameDestructionObserver.h" -#include "core/platform/graphics/FloatRect.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameDestructionObserver.h" +#include "platform/geometry/FloatRect.h" #include "public/platform/WebFileSystemType.h" #include "wtf/Compiler.h" #include "wtf/OwnPtr.h" @@ -76,10 +76,11 @@ class WebFrameImpl , public WebCore::FrameDestructionObserver { public: // WebFrame methods: + virtual void close(); virtual WebString uniqueName() const; virtual WebString assignedName() const; virtual void setName(const WebString&); - virtual long long identifier() const; + virtual long long embedderIdentifier() const; virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const; virtual WebSize scrollOffset() const; virtual void setScrollOffset(const WebSize&); @@ -237,7 +238,10 @@ public: // WebCore::FrameDestructionObserver methods. virtual void willDetachPage(); - static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); + static WebFrameImpl* create(WebFrameClient*); + // FIXME: Move the embedderIdentifier concept fully to the embedder and + // remove this factory method. + static WebFrameImpl* create(WebFrameClient*, long long embedderIdentifier); virtual ~WebFrameImpl(); // Called by the WebViewImpl to initialize the main frame for the page. @@ -298,6 +302,8 @@ public: WebFrameClient* client() const { return m_client; } void setClient(WebFrameClient* client) { m_client = client; } + void setInputEventsScaleFactorForEmulation(float); + static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition); private: @@ -326,7 +332,7 @@ private: InvalidateAll // Both content area and the scrollbar. }; - explicit WebFrameImpl(WebFrameClient*); + WebFrameImpl(WebFrameClient*, long long frame_identifier); // Sets the local WebCore frame and registers destruction observers. void setWebCoreFrame(WebCore::Frame*); @@ -490,11 +496,14 @@ private: OwnPtr<ChromePrintContext> m_printContext; // The identifier of this frame. - long long m_identifier; + long long m_embedderIdentifier; // Ensure we don't overwrite valid history data during same document loads // from HistoryItems bool m_inSameDocumentHistoryLoad; + + // Stores the additional input evetns scale when device metrics emulation is enabled. + float m_inputEventsScaleFactorForEmulation; }; inline WebFrameImpl* toWebFrameImpl(WebFrame* webFrame) diff --git a/Source/web/WebGeolocationPermissionRequest.cpp b/Source/web/WebGeolocationPermissionRequest.cpp index 0cb974111..5731c8d86 100644 --- a/Source/web/WebGeolocationPermissionRequest.cpp +++ b/Source/web/WebGeolocationPermissionRequest.cpp @@ -28,7 +28,7 @@ #include "public/platform/WebURL.h" #include "WebSecurityOrigin.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "modules/geolocation/Geolocation.h" #include "weborigin/SecurityOrigin.h" @@ -38,7 +38,7 @@ namespace WebKit { WebSecurityOrigin WebGeolocationPermissionRequest::securityOrigin() const { - return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin()); + return WebSecurityOrigin(m_private->executionContext()->securityOrigin()); } void WebGeolocationPermissionRequest::setIsAllowed(bool allowed) diff --git a/Source/web/WebHelperPluginImpl.cpp b/Source/web/WebHelperPluginImpl.cpp index 8c8197482..4520beab6 100644 --- a/Source/web/WebHelperPluginImpl.cpp +++ b/Source/web/WebHelperPluginImpl.cpp @@ -44,7 +44,7 @@ #include "core/loader/DocumentLoader.h" #include "core/loader/EmptyClients.h" #include "core/page/FocusController.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/Settings.h" @@ -109,6 +109,7 @@ private: WebHelperPluginImpl::WebHelperPluginImpl(WebWidgetClient* client) : m_widgetClient(client) , m_webView(0) + , m_mainFrame(0) { ASSERT(client); } @@ -143,13 +144,14 @@ void WebHelperPluginImpl::closeHelperPlugin() // closeWidgetSoon() will call this->close() later. m_widgetClient->closeWidgetSoon(); } + m_mainFrame->close(); } void WebHelperPluginImpl::initializeFrame(WebFrameClient* client) { ASSERT(m_page); - RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client); - frame->initializeAsMainFrame(m_page.get()); + m_mainFrame = WebFrameImpl::create(client); + m_mainFrame->initializeAsMainFrame(m_page.get()); } // Returns a pointer to the WebPlugin by finding the single <object> tag in the page. @@ -188,9 +190,6 @@ bool WebHelperPluginImpl::initializePage(const String& pluginType, const WebDocu ASSERT(!m_page->settings().isScriptEnabled()); m_page->settings().setPluginsEnabled(true); - unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout; - m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones)); - m_webView->client()->initializeHelperPluginWebFrame(this); // The page's main frame was set in initializeFrame() as a result of the above call. diff --git a/Source/web/WebHelperPluginImpl.h b/Source/web/WebHelperPluginImpl.h index 0b06b32aa..93f38f994 100644 --- a/Source/web/WebHelperPluginImpl.h +++ b/Source/web/WebHelperPluginImpl.h @@ -43,7 +43,7 @@ namespace WebKit { class HelperPluginChromeClient; class WebDocument; -class WebFrame; +class WebFrameImpl; class WebViewImpl; class WebWidgetClient; @@ -72,9 +72,11 @@ private: virtual void layout() OVERRIDE; virtual void setFocus(bool) OVERRIDE; virtual void close() OVERRIDE; + virtual bool isHelperPlugin() const OVERRIDE { return true; } WebWidgetClient* m_widgetClient; WebViewImpl* m_webView; + WebFrameImpl* m_mainFrame; OwnPtr<WebCore::Page> m_page; OwnPtr<HelperPluginChromeClient> m_chromeClient; @@ -82,6 +84,12 @@ private: friend class HelperPluginChromeClient; }; +inline WebHelperPluginImpl* toWebHelperPluginImpl(WebWidget* widget) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!widget || widget->isHelperPlugin()); + return static_cast<WebHelperPluginImpl*>(widget); +} + } // namespace WebKit #endif // WebHelperPluginImpl_h diff --git a/Source/web/WebHistoryItem.cpp b/Source/web/WebHistoryItem.cpp index db107a3e8..612fcfa89 100644 --- a/Source/web/WebHistoryItem.cpp +++ b/Source/web/WebHistoryItem.cpp @@ -129,55 +129,6 @@ void WebHistoryItem::setTarget(const WebString& target) m_private->setTarget(target); } -WebString WebHistoryItem::parent() const -{ - return m_private->parent(); -} - -void WebHistoryItem::setParent(const WebString& parent) -{ - ensureMutable(); - m_private->setParent(parent); -} - -WebString WebHistoryItem::title() const -{ - return m_private->title(); -} - -void WebHistoryItem::setTitle(const WebString& title) -{ - ensureMutable(); - m_private->setTitle(title); -} - -WebString WebHistoryItem::alternateTitle() const -{ - return m_private->alternateTitle(); -} - -void WebHistoryItem::setAlternateTitle(const WebString& alternateTitle) -{ - ensureMutable(); - m_private->setAlternateTitle(alternateTitle); -} - -double WebHistoryItem::lastVisitedTime() const -{ - return m_private->lastVisitedTime(); -} - -void WebHistoryItem::setLastVisitedTime(double lastVisitedTime) -{ - ensureMutable(); - // FIXME: setLastVisitedTime increments the visit count, so we have to - // correct for that. Instead, we should have a back-door to just mutate - // the last visited time directly. - int count = m_private->visitCount(); - m_private->setLastVisitedTime(lastVisitedTime); - m_private->setVisitCount(count); -} - WebPoint WebHistoryItem::scrollOffset() const { return m_private->scrollPoint(); @@ -200,28 +151,6 @@ void WebHistoryItem::setPageScaleFactor(float scale) m_private->setPageScaleFactor(scale); } -bool WebHistoryItem::isTargetItem() const -{ - return m_private->isTargetItem(); -} - -void WebHistoryItem::setIsTargetItem(bool isTargetItem) -{ - ensureMutable(); - m_private->setIsTargetItem(isTargetItem); -} - -int WebHistoryItem::visitCount() const -{ - return m_private->visitCount(); -} - -void WebHistoryItem::setVisitCount(int count) -{ - ensureMutable(); - m_private->setVisitCount(count); -} - WebVector<WebString> WebHistoryItem::documentState() const { return m_private->documentState(); @@ -297,14 +226,6 @@ WebVector<WebHistoryItem> WebHistoryItem::children() const return m_private->children(); } -void WebHistoryItem::setChildren(const WebVector<WebHistoryItem>& items) -{ - ensureMutable(); - m_private->clearChildren(); - for (size_t i = 0; i < items.size(); ++i) - m_private->addChildItem(items[i]); -} - void WebHistoryItem::appendToChildren(const WebHistoryItem& item) { ensureMutable(); diff --git a/Source/web/WebImageDecoder.cpp b/Source/web/WebImageDecoder.cpp index 728886065..6b5fd009b 100644 --- a/Source/web/WebImageDecoder.cpp +++ b/Source/web/WebImageDecoder.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "WebImageDecoder.h" -#include "core/platform/SharedBuffer.h" +#include "platform/SharedBuffer.h" #include "core/platform/image-decoders/bmp/BMPImageDecoder.h" #include "core/platform/image-decoders/ico/ICOImageDecoder.h" #include "public/platform/Platform.h" diff --git a/Source/web/WebImageSkia.cpp b/Source/web/WebImageSkia.cpp index b6ba42d14..eadc1d9dd 100644 --- a/Source/web/WebImageSkia.cpp +++ b/Source/web/WebImageSkia.cpp @@ -31,7 +31,7 @@ #include "config.h" #include <algorithm> -#include "core/platform/SharedBuffer.h" +#include "platform/SharedBuffer.h" #include "core/platform/graphics/Image.h" #include "core/platform/graphics/skia/NativeImageSkia.h" #include "core/platform/image-decoders/ImageDecoder.h" diff --git a/Source/web/WebInputElement.cpp b/Source/web/WebInputElement.cpp index 9a1a3fd34..34891c709 100644 --- a/Source/web/WebInputElement.cpp +++ b/Source/web/WebInputElement.cpp @@ -142,16 +142,6 @@ WebString WebInputElement::placeholder() const return constUnwrap<HTMLInputElement>()->fastGetAttribute(HTMLNames::placeholderAttr); } -bool WebInputElement::isAutofilled() const -{ - return constUnwrap<HTMLInputElement>()->isAutofilled(); -} - -void WebInputElement::setAutofilled(bool autofilled) -{ - unwrap<HTMLInputElement>()->setAutofilled(autofilled); -} - void WebInputElement::setSelectionRange(int start, int end) { unwrap<HTMLInputElement>()->setSelectionRange(start, end); diff --git a/Source/web/WebInputEventConversion.cpp b/Source/web/WebInputEventConversion.cpp index 1c7669eef..402950137 100644 --- a/Source/web/WebInputEventConversion.cpp +++ b/Source/web/WebInputEventConversion.cpp @@ -32,21 +32,21 @@ #include "WebInputEventConversion.h" #include "WebInputEvent.h" -#include "core/events/EventNames.h" +#include "core/dom/Touch.h" +#include "core/dom/TouchList.h" #include "core/events/GestureEvent.h" #include "core/events/KeyboardEvent.h" #include "core/events/MouseEvent.h" -#include "core/dom/Touch.h" +#include "core/events/ThreadLocalEventNames.h" #include "core/events/TouchEvent.h" -#include "core/dom/TouchList.h" #include "core/events/WheelEvent.h" -#include "core/platform/PlatformKeyboardEvent.h" -#include "core/platform/PlatformMouseEvent.h" -#include "core/platform/PlatformWheelEvent.h" #include "core/platform/ScrollView.h" -#include "core/platform/Widget.h" #include "core/platform/chromium/KeyboardCodes.h" #include "core/rendering/RenderObject.h" +#include "platform/PlatformKeyboardEvent.h" +#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformWheelEvent.h" +#include "platform/Widget.h" using namespace WebCore; @@ -54,23 +54,23 @@ namespace WebKit { static const double millisPerSecond = 1000.0; -static float widgetScaleFactor(const Widget* widget) +static float widgetInputEventsScaleFactor(const Widget* widget) { if (!widget) return 1; - ScrollView* rootView = widget->root(); + ScrollView* rootView = toScrollView(widget->root()); if (!rootView) return 1; - return rootView->visibleContentScaleFactor(); + return rootView->inputEventsScaleFactor(); } // MakePlatformMouseEvent ----------------------------------------------------- PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e) { - float scale = widgetScaleFactor(widget); + float scale = widgetInputEventsScaleFactor(widget); // FIXME: Widget is always toplevel, unless it's a popup. We may be able // to get rid of this once we abstract popups into a WebKit API. m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale)); @@ -115,7 +115,7 @@ PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e) { - float scale = widgetScaleFactor(widget); + float scale = widgetInputEventsScaleFactor(widget); m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale)); m_globalPosition = IntPoint(e.globalX, e.globalY); m_deltaX = e.deltaX; @@ -152,7 +152,7 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const WebGestureEvent& e) { - float scale = widgetScaleFactor(widget); + float scale = widgetInputEventsScaleFactor(widget); switch (e.type) { case WebInputEvent::GestureScrollBegin: m_type = PlatformEvent::GestureScrollBegin; @@ -162,26 +162,32 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W break; case WebInputEvent::GestureScrollUpdate: m_type = PlatformEvent::GestureScrollUpdate; - m_deltaX = e.data.scrollUpdate.deltaX / scale; - m_deltaY = e.data.scrollUpdate.deltaY / scale; + m_data.m_scrollUpdate.m_deltaX = e.data.scrollUpdate.deltaX / scale; + m_data.m_scrollUpdate.m_deltaY = e.data.scrollUpdate.deltaY / scale; + m_data.m_scrollUpdate.m_velocityX = e.data.scrollUpdate.velocityX; + m_data.m_scrollUpdate.m_velocityY = e.data.scrollUpdate.velocityY; break; case WebInputEvent::GestureScrollUpdateWithoutPropagation: m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation; - m_deltaX = e.data.scrollUpdate.deltaX / scale; - m_deltaY = e.data.scrollUpdate.deltaY / scale; + m_data.m_scrollUpdate.m_deltaX = e.data.scrollUpdate.deltaX / scale; + m_data.m_scrollUpdate.m_deltaY = e.data.scrollUpdate.deltaY / scale; + m_data.m_scrollUpdate.m_velocityX = e.data.scrollUpdate.velocityX; + m_data.m_scrollUpdate.m_velocityY = e.data.scrollUpdate.velocityY; break; case WebInputEvent::GestureTap: m_type = PlatformEvent::GestureTap; m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale)); - // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123 - m_deltaX = static_cast<int>(e.data.tap.tapCount); + m_data.m_tap.m_tapCount = e.data.tap.tapCount; break; case WebInputEvent::GestureTapUnconfirmed: m_type = PlatformEvent::GestureTapUnconfirmed; m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale)); break; + // TODO - once chrome passes GestureShowPress and GestureTapDown events correctly, + // don't retype tap down events. See crbug.com/302752. case WebInputEvent::GestureTapDown: - m_type = PlatformEvent::GestureTapDown; + case WebInputEvent::GestureShowPress: + m_type = PlatformEvent::GestureShowPress; m_area = expandedIntSize(FloatSize(e.data.tapDown.width / scale, e.data.tapDown.height / scale)); break; case WebInputEvent::GestureTapCancel: @@ -214,8 +220,7 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W break; case WebInputEvent::GesturePinchUpdate: m_type = PlatformEvent::GesturePinchUpdate; - // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123 - m_deltaX = e.data.pinchUpdate.scale; + m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; break; default: ASSERT_NOT_REACHED(); @@ -367,20 +372,20 @@ inline PlatformTouchPoint::State toPlatformTouchPointState(const WebTouchPoint:: inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type) { - if (type == eventNames().touchendEvent) + if (type == EventTypeNames::touchend) return WebTouchPoint::StateReleased; - if (type == eventNames().touchcancelEvent) + if (type == EventTypeNames::touchcancel) return WebTouchPoint::StateCancelled; - if (type == eventNames().touchstartEvent) + if (type == EventTypeNames::touchstart) return WebTouchPoint::StatePressed; - if (type == eventNames().touchmoveEvent) + if (type == EventTypeNames::touchmove) return WebTouchPoint::StateMoved; return WebTouchPoint::StateUndefined; } PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point) { - float scale = widgetScaleFactor(widget); + float scale = widgetInputEventsScaleFactor(widget); m_id = point.id; m_state = toPlatformTouchPointState(point.state); m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scale, point.position.y / scale)); @@ -435,7 +440,7 @@ static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; webEvent.modifiers = getWebInputModifiers(event); - ScrollView* view = widget.parent(); + ScrollView* view = toScrollView(widget.parent()); IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y()); if (view) windowPoint = view->contentsToWindow(windowPoint); @@ -450,17 +455,17 @@ static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const MouseEvent& event) { - if (event.type() == eventNames().mousemoveEvent) + if (event.type() == EventTypeNames::mousemove) type = WebInputEvent::MouseMove; - else if (event.type() == eventNames().mouseoutEvent) + else if (event.type() == EventTypeNames::mouseout) type = WebInputEvent::MouseLeave; - else if (event.type() == eventNames().mouseoverEvent) + else if (event.type() == EventTypeNames::mouseover) type = WebInputEvent::MouseEnter; - else if (event.type() == eventNames().mousedownEvent) + else if (event.type() == EventTypeNames::mousedown) type = WebInputEvent::MouseDown; - else if (event.type() == eventNames().mouseupEvent) + else if (event.type() == EventTypeNames::mouseup) type = WebInputEvent::MouseUp; - else if (event.type() == eventNames().contextmenuEvent) + else if (event.type() == EventTypeNames::contextmenu) type = WebInputEvent::ContextMenu; else return; // Skip all other mouse events. @@ -502,7 +507,7 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore:: if (!event.touches()) return; if (event.touches()->length() != 1) { - if (event.touches()->length() || event.type() != eventNames().touchendEvent || !event.changedTouches() || event.changedTouches()->length() != 1) + if (event.touches()->length() || event.type() != EventTypeNames::touchend || !event.changedTouches() || event.changedTouches()->length() != 1) return; } @@ -510,11 +515,11 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore:: if (touch->identifier()) return; - if (event.type() == eventNames().touchstartEvent) + if (event.type() == EventTypeNames::touchstart) type = MouseDown; - else if (event.type() == eventNames().touchmoveEvent) + else if (event.type() == EventTypeNames::touchmove) type = MouseMove; - else if (event.type() == eventNames().touchendEvent) + else if (event.type() == EventTypeNames::touchend) type = MouseUp; else return; @@ -563,7 +568,7 @@ WebMouseEventBuilder::WebMouseEventBuilder(const WebCore::Widget* widget, const // FIXME: Widget is always toplevel, unless it's a popup. We may be able // to get rid of this once we abstract popups into a WebKit API. IntPoint position = widget->convertToContainingWindow(event.position()); - float scale = widgetScaleFactor(widget); + float scale = widgetInputEventsScaleFactor(widget); position.scale(scale, scale); x = position.x(); y = position.y(); @@ -578,7 +583,7 @@ WebMouseEventBuilder::WebMouseEventBuilder(const WebCore::Widget* widget, const WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const WheelEvent& event) { - if (event.type() != eventNames().wheelEvent && event.type() != eventNames().mousewheelEvent) + if (event.type() != EventTypeNames::wheel && event.type() != EventTypeNames::mousewheel) return; type = WebInputEvent::MouseWheel; updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *this); @@ -591,11 +596,11 @@ WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) { - if (event.type() == eventNames().keydownEvent) + if (event.type() == EventTypeNames::keydown) type = KeyDown; - else if (event.type() == eventNames().keyupEvent) + else if (event.type() == EventTypeNames::keyup) type = WebInputEvent::KeyUp; - else if (event.type() == eventNames().keypressEvent) + else if (event.type() == EventTypeNames::keypress) type = WebInputEvent::Char; else return; // Skip all other keyboard events. @@ -696,13 +701,13 @@ static void addTouchPoints(const Widget* widget, const AtomicString& touchType, WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event) { - if (event.type() == eventNames().touchstartEvent) + if (event.type() == EventTypeNames::touchstart) type = TouchStart; - else if (event.type() == eventNames().touchmoveEvent) + else if (event.type() == EventTypeNames::touchmove) type = TouchMove; - else if (event.type() == eventNames().touchendEvent) + else if (event.type() == EventTypeNames::touchend) type = TouchEnd; - else if (event.type() == eventNames().touchcancelEvent) + else if (event.type() == EventTypeNames::touchcancel) type = TouchCancel; else { ASSERT_NOT_REACHED(); @@ -720,15 +725,17 @@ WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore:: WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const GestureEvent& event) { - if (event.type() == eventNames().gesturetapEvent) + if (event.type() == EventTypeNames::gesturetap) type = GestureTap; - else if (event.type() == eventNames().gesturetapdownEvent) + else if (event.type() == EventTypeNames::gestureshowpress) + type = GestureShowPress; + else if (event.type() == EventTypeNames::gesturetapdown) type = GestureTapDown; - else if (event.type() == eventNames().gesturescrollstartEvent) + else if (event.type() == EventTypeNames::gesturescrollstart) type = GestureScrollBegin; - else if (event.type() == eventNames().gesturescrollendEvent) + else if (event.type() == EventTypeNames::gesturescrollend) type = GestureScrollEnd; - else if (event.type() == eventNames().gesturescrollupdateEvent) { + else if (event.type() == EventTypeNames::gesturescrollupdate) { type = GestureScrollUpdate; data.scrollUpdate.deltaX = event.deltaX(); data.scrollUpdate.deltaY = event.deltaY(); diff --git a/Source/web/WebInputEventConversion.h b/Source/web/WebInputEventConversion.h index 14e39ee1b..bc7875329 100644 --- a/Source/web/WebInputEventConversion.h +++ b/Source/web/WebInputEventConversion.h @@ -32,11 +32,11 @@ #define WebInputEventConversion_h #include "WebInputEvent.h" -#include "core/platform/PlatformGestureEvent.h" -#include "core/platform/PlatformKeyboardEvent.h" -#include "core/platform/PlatformMouseEvent.h" -#include "core/platform/PlatformTouchEvent.h" -#include "core/platform/PlatformWheelEvent.h" +#include "platform/PlatformGestureEvent.h" +#include "platform/PlatformKeyboardEvent.h" +#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformTouchEvent.h" +#include "platform/PlatformWheelEvent.h" namespace WebCore { class GestureEvent; diff --git a/Source/web/WebKit.cpp b/Source/web/WebKit.cpp index 4b8b45d72..d33d80ace 100644 --- a/Source/web/WebKit.cpp +++ b/Source/web/WebKit.cpp @@ -41,8 +41,8 @@ #include "core/dom/Microtask.h" #include "core/page/Page.h" #include "core/page/Settings.h" -#include "core/platform/LayoutTestSupport.h" -#include "core/platform/Logging.h" +#include "platform/LayoutTestSupport.h" +#include "platform/Logging.h" #include "core/platform/graphics/MediaPlayer.h" #include "core/platform/graphics/chromium/ImageDecodingStore.h" #include "core/workers/WorkerGlobalScopeProxy.h" @@ -185,10 +185,10 @@ void shutdown() s_endOfTaskRunner = 0; } - shutdownWithoutV8(); - WebCore::V8PerIsolateData::dispose(v8::Isolate::GetCurrent()); v8::V8::Dispose(); + + shutdownWithoutV8(); } void shutdownWithoutV8() diff --git a/Source/web/WebKitUnitTests.isolate b/Source/web/WebKitUnitTests.isolate index b7cf8c15a..d48b23142 100644 --- a/Source/web/WebKitUnitTests.isolate +++ b/Source/web/WebKitUnitTests.isolate @@ -37,6 +37,7 @@ 'isolate_dependency_untracked': [ 'tests/data/', # Required by some image decoder tests. + '../core/platform/image-decoders/testing/', '../../LayoutTests/fast/images/resources/', ], }, diff --git a/Source/web/WebMIDIClientMock.cpp b/Source/web/WebMIDIClientMock.cpp index 658e2677a..923e03a6a 100644 --- a/Source/web/WebMIDIClientMock.cpp +++ b/Source/web/WebMIDIClientMock.cpp @@ -31,8 +31,8 @@ #include "config.h" #include "WebMIDIClientMock.h" -#include "core/platform/mock/MIDIClientMock.h" #include "modules/webmidi/MIDIAccess.h" +#include "modules/webmidi/MIDIClientMock.h" #include "public/web/WebMIDIPermissionRequest.h" namespace WebKit { diff --git a/Source/web/WebMIDIPermissionRequest.cpp b/Source/web/WebMIDIPermissionRequest.cpp index 869fa2ced..977045ed1 100644 --- a/Source/web/WebMIDIPermissionRequest.cpp +++ b/Source/web/WebMIDIPermissionRequest.cpp @@ -67,7 +67,7 @@ bool WebMIDIPermissionRequest::equals(const WebMIDIPermissionRequest& n) const WebSecurityOrigin WebMIDIPermissionRequest::securityOrigin() const { - return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin()); + return WebSecurityOrigin(m_private->executionContext()->securityOrigin()); } void WebMIDIPermissionRequest::setIsAllowed(bool allowed) diff --git a/Source/web/WebMediaPlayerClientImpl.cpp b/Source/web/WebMediaPlayerClientImpl.cpp index ee6023043..7c0c0865e 100644 --- a/Source/web/WebMediaPlayerClientImpl.cpp +++ b/Source/web/WebMediaPlayerClientImpl.cpp @@ -7,7 +7,6 @@ #include "InbandTextTrackPrivateImpl.h" #include "MediaSourcePrivateImpl.h" -#include "WebAudioSourceProvider.h" #include "WebDocument.h" #include "WebFrameClient.h" #include "WebFrameImpl.h" @@ -18,18 +17,19 @@ #include "core/html/HTMLMediaElement.h" #include "core/html/HTMLMediaSource.h" #include "core/html/TimeRanges.h" -#include "core/page/Frame.h" -#include "core/platform/NotImplemented.h" -#include "core/platform/audio/AudioBus.h" -#include "core/platform/audio/AudioSourceProvider.h" -#include "core/platform/audio/AudioSourceProviderClient.h" +#include "core/frame/Frame.h" +#include "platform/NotImplemented.h" +#include "platform/audio/AudioBus.h" +#include "platform/audio/AudioSourceProvider.h" +#include "platform/audio/AudioSourceProviderClient.h" #include "core/platform/graphics/GraphicsContext.h" #include "core/platform/graphics/GraphicsLayer.h" -#include "core/platform/graphics/IntSize.h" #include "core/platform/graphics/MediaPlayer.h" #include "core/rendering/RenderLayerCompositor.h" #include "core/rendering/RenderView.h" #include "modules/mediastream/MediaStreamRegistry.h" +#include "platform/geometry/IntSize.h" +#include "public/platform/WebAudioSourceProvider.h" #include "public/platform/WebCanvas.h" #include "public/platform/WebCompositorSupport.h" #include "public/platform/WebCString.h" @@ -165,7 +165,7 @@ WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginT if (!plugin) { // There is no need to keep the helper plugin around and the caller // should not be expected to call close after a failure (null pointer). - closeHelperPlugin(); + closeHelperPluginSoon(frame); return 0; } @@ -173,14 +173,6 @@ WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginT } -// FIXME: Remove this override and cast when Chromium is updated to use closeHelperPluginSoon(). -void WebMediaPlayerClientImpl::closeHelperPlugin() -{ - Frame* frame = static_cast<HTMLMediaElement*>(m_client)->document().frame(); - WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); - closeHelperPluginSoon(webFrame); -} - void WebMediaPlayerClientImpl::closeHelperPluginSoon(WebFrame* frame) { ASSERT(m_helperPlugin); @@ -224,6 +216,11 @@ void WebMediaPlayerClientImpl::mediaSourceOpened(WebMediaSource* webMediaSource) m_mediaSource->setPrivateAndOpen(adoptPtr(new MediaSourcePrivateImpl(adoptPtr(webMediaSource)))); } +void WebMediaPlayerClientImpl::requestFullscreen() +{ + m_client->mediaPlayerRequestFullscreen(); +} + void WebMediaPlayerClientImpl::requestSeek(double time) { m_client->mediaPlayerRequestSeek(time); diff --git a/Source/web/WebMediaPlayerClientImpl.h b/Source/web/WebMediaPlayerClientImpl.h index 2b1a6325b..82915fcea 100644 --- a/Source/web/WebMediaPlayerClientImpl.h +++ b/Source/web/WebMediaPlayerClientImpl.h @@ -33,7 +33,7 @@ #include "WebAudioSourceProviderClient.h" #include "WebMediaPlayerClient.h" -#include "core/platform/audio/AudioSourceProvider.h" +#include "platform/audio/AudioSourceProvider.h" #include "core/platform/graphics/InbandTextTrackPrivate.h" #include "core/platform/graphics/MediaPlayer.h" #if OS(ANDROID) @@ -84,13 +84,13 @@ public: virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL); virtual void keyNeeded(const WebString& keySystem, const WebString& sessionId, const unsigned char* initData, unsigned initDataLength); virtual WebPlugin* createHelperPlugin(const WebString& pluginType, WebFrame*); - virtual void closeHelperPlugin(); virtual void closeHelperPluginSoon(WebFrame*); virtual bool needsWebLayerForVideo() const; virtual void setWebLayer(WebLayer*); virtual void addTextTrack(WebInbandTextTrack*); virtual void removeTextTrack(WebInbandTextTrack*); virtual void mediaSourceOpened(WebMediaSource*); + virtual void requestFullscreen(); virtual void requestSeek(double); // MediaPlayer methods: diff --git a/Source/web/WebNetworkStateNotifier.cpp b/Source/web/WebNetworkStateNotifier.cpp index 96c18c998..6a969f80f 100644 --- a/Source/web/WebNetworkStateNotifier.cpp +++ b/Source/web/WebNetworkStateNotifier.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "WebNetworkStateNotifier.h" -#include "core/platform/network/NetworkStateNotifier.h" +#include "core/page/NetworkStateNotifier.h" using namespace WebCore; diff --git a/Source/web/WebNode.cpp b/Source/web/WebNode.cpp index fabdad9b1..845259089 100644 --- a/Source/web/WebNode.cpp +++ b/Source/web/WebNode.cpp @@ -48,9 +48,9 @@ #include "core/dom/Node.h" #include "core/dom/NodeList.h" #include "core/editing/markup.h" -#include "core/platform/Widget.h" #include "core/rendering/RenderObject.h" #include "core/rendering/RenderWidget.h" +#include "platform/Widget.h" #include "public/platform/WebString.h" #include "public/platform/WebVector.h" diff --git a/Source/web/WebNotification.cpp b/Source/web/WebNotification.cpp index 129134397..7e2cb2e8c 100644 --- a/Source/web/WebNotification.cpp +++ b/Source/web/WebNotification.cpp @@ -33,9 +33,9 @@ #include "WebTextDirection.h" #include "core/events/Event.h" -#include "core/dom/UserGestureIndicator.h" #include "core/page/WindowFocusAllowedIndicator.h" #include "modules/notifications/Notification.h" +#include "platform/UserGestureIndicator.h" #include "public/platform/WebString.h" #include "public/platform/WebURL.h" #include "wtf/PassRefPtr.h" diff --git a/Source/web/WebPagePopupImpl.cpp b/Source/web/WebPagePopupImpl.cpp index 1bf3d04ba..24f198153 100644 --- a/Source/web/WebPagePopupImpl.cpp +++ b/Source/web/WebPagePopupImpl.cpp @@ -46,8 +46,8 @@ #include "core/page/DOMWindowPagePopup.h" #include "core/page/EventHandler.h" #include "core/page/FocusController.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/PagePopupClient.h" #include "core/page/Settings.h" @@ -201,9 +201,6 @@ bool WebPagePopupImpl::initializePage() m_page->setDeviceScaleFactor(m_webView->deviceScaleFactor()); m_page->settings().setDeviceSupportsTouch(m_webView->page()->settings().deviceSupportsTouch()); - unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout; - m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones)); - static ContextFeaturesClient* pagePopupFeaturesClient = new PagePopupFeaturesClient(); provideContextFeaturesTo(m_page.get(), pagePopupFeaturesClient); static FrameLoaderClient* emptyFrameLoaderClient = new EmptyFrameLoaderClient(); diff --git a/Source/web/WebPagePopupImpl.h b/Source/web/WebPagePopupImpl.h index a3c1cfb56..74641ff31 100644 --- a/Source/web/WebPagePopupImpl.h +++ b/Source/web/WebPagePopupImpl.h @@ -73,6 +73,7 @@ private: virtual void close() OVERRIDE; virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE; virtual void setFocus(bool) OVERRIDE; + virtual bool isPagePopup() const OVERRIDE { return true; } // PageWidgetEventHandler functions virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE; @@ -95,5 +96,18 @@ private: friend class PagePopupChromeClient; }; +inline WebPagePopupImpl* toWebPagePopupImpl(WebWidget* widget) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!widget || widget->isPagePopup()); + return static_cast<WebPagePopupImpl*>(widget); +} + +inline WebPagePopupImpl* toWebPagePopupImpl(WebCore::PagePopup* popup) +{ + // WebPagePopupImpl is the only implementation of WebCore::PagePopup, so + // no further checking required. + return static_cast<WebPagePopupImpl*>(popup); +} + } // namespace WebKit #endif // WebPagePopupImpl_h diff --git a/Source/web/WebPageSerializer.cpp b/Source/web/WebPageSerializer.cpp index 964f85d0f..1e2788905 100644 --- a/Source/web/WebPageSerializer.cpp +++ b/Source/web/WebPageSerializer.cpp @@ -46,7 +46,7 @@ #include "core/html/HTMLTableElement.h" #include "core/loader/DocumentLoader.h" #include "core/loader/archive/MHTMLArchive.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include "core/page/PageSerializer.h" #include "core/platform/SerializedResource.h" #include "public/platform/WebCString.h" diff --git a/Source/web/WebPerformance.cpp b/Source/web/WebPerformance.cpp index 8f8b5047d..7490801e4 100644 --- a/Source/web/WebPerformance.cpp +++ b/Source/web/WebPerformance.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "WebPerformance.h" -#include "core/page/Performance.h" +#include "core/timing/Performance.h" using namespace WebCore; diff --git a/Source/web/WebPluginContainerImpl.cpp b/Source/web/WebPluginContainerImpl.cpp index ab829a5c3..713d2c2f7 100644 --- a/Source/web/WebPluginContainerImpl.cpp +++ b/Source/web/WebPluginContainerImpl.cpp @@ -43,40 +43,40 @@ #include "WebViewImpl.h" #include "core/page/Chrome.h" #include "core/page/EventHandler.h" -#include "core/platform/chromium/ClipboardChromium.h" #include "core/platform/chromium/support/WrappedResourceResponse.h" #include "HTMLNames.h" #include "WebPrintParams.h" #include "bindings/v8/ScriptController.h" -#include "core/events/EventNames.h" +#include "core/dom/Clipboard.h" #include "core/events/GestureEvent.h" #include "core/events/KeyboardEvent.h" #include "core/events/MouseEvent.h" -#include "core/dom/TouchController.h" +#include "core/events/ThreadLocalEventNames.h" #include "core/events/TouchEvent.h" -#include "core/dom/UserGestureIndicator.h" #include "core/events/WheelEvent.h" #include "core/html/HTMLFormElement.h" #include "core/html/HTMLPlugInElement.h" #include "core/loader/FormState.h" #include "core/loader/FrameLoadRequest.h" #include "core/page/FocusController.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/scrolling/ScrollingCoordinator.h" -#include "core/platform/HostWindow.h" -#include "core/platform/PlatformGestureEvent.h" #include "core/platform/ScrollAnimator.h" #include "core/platform/ScrollView.h" #include "core/platform/ScrollbarTheme.h" +#include "core/platform/chromium/ChromiumDataObject.h" #include "core/platform/chromium/KeyboardCodes.h" #include "core/platform/graphics/GraphicsContext.h" #include "core/platform/graphics/GraphicsLayer.h" #include "core/plugins/PluginOcclusionSupport.h" #include "core/rendering/HitTestResult.h" #include "core/rendering/RenderBox.h" +#include "platform/HostWindow.h" +#include "platform/PlatformGestureEvent.h" +#include "platform/UserGestureIndicator.h" #include "public/platform/Platform.h" #include "public/platform/WebClipboard.h" #include "public/platform/WebCompositorSupport.h" @@ -124,7 +124,7 @@ void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRec gc->save(); ASSERT(parent()->isFrameView()); - ScrollView* view = parent(); + ScrollView* view = toScrollView(parent()); // The plugin is positioned in window coordinates, so it needs to be painted // in window coordinates. @@ -189,14 +189,14 @@ void WebPluginContainerImpl::handleEvent(Event* event) // where mozilla behaves differently than the spec. if (event->isMouseEvent()) handleMouseEvent(toMouseEvent(event)); - else if (event->hasInterface(eventNames().interfaceForWheelEvent)) - handleWheelEvent(static_cast<WheelEvent*>(event)); + else if (event->isWheelEvent()) + handleWheelEvent(toWheelEvent(event)); else if (event->isKeyboardEvent()) handleKeyboardEvent(toKeyboardEvent(event)); - else if (eventNames().isTouchEventType(event->type())) + else if (event->isTouchEvent()) handleTouchEvent(toTouchEvent(event)); - else if (eventNames().isGestureEventType(event->type())) - handleGestureEvent(static_cast<GestureEvent*>(event)); + else if (event->isGestureEvent()) + handleGestureEvent(toGestureEvent(event)); // FIXME: it would be cleaner if Widget::handleEvent returned true/false and // HTMLPluginElement called setDefaultHandled or defaultEventHandler. @@ -246,15 +246,15 @@ void WebPluginContainerImpl::setParentVisible(bool parentVisible) m_webPlugin->updateVisibility(isVisible()); } -void WebPluginContainerImpl::setParent(ScrollView* view) +void WebPluginContainerImpl::setParent(Widget* widget) { // We override this function so that if the plugin is windowed, we can call // NPP_SetWindow at the first possible moment. This ensures that // NPP_SetWindow is called before the manual load data is sent to a plugin. // If this order is reversed, Flash won't load videos. - Widget::setParent(view); - if (view) + Widget::setParent(widget); + if (widget) reportGeometry(); } @@ -441,7 +441,8 @@ WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup String script = decodeURLEscapeSequences( kurl.string().substring(strlen("javascript:"))); - ScriptValue result = frame->script()->executeScript(script, popupsAllowed); + UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNewUserGesture : PossiblyProcessingUserGesture); + ScriptValue result = frame->script()->executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script)); // Failure is reported as a null string. String resultStr; @@ -500,11 +501,10 @@ void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType request if (m_touchEventRequestType == requestType) return; - Document& document = m_element->document(); if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == TouchEventRequestTypeNone) - TouchController::from(&document)->didAddTouchEventHandler(&document, m_element); + m_element->document().didAddTouchEventHandler(m_element); else if (requestType == TouchEventRequestTypeNone && m_touchEventRequestType != TouchEventRequestTypeNone) - TouchController::from(&document)->didRemoveTouchEventHandler(&document, m_element); + m_element->document().didRemoveTouchEventHandler(m_element); m_touchEventRequestType = requestType; } @@ -523,7 +523,7 @@ void WebPluginContainerImpl::setWantsWheelEvents(bool wantsWheelEvents) WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point) { - ScrollView* view = parent(); + ScrollView* view = toScrollView(parent()); if (!view) return point; WebPoint windowPoint = view->windowToContents(point); @@ -532,7 +532,7 @@ WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point) WebPoint WebPluginContainerImpl::localToWindowPoint(const WebPoint& point) { - ScrollView* view = parent(); + ScrollView* view = toScrollView(parent()); if (!view) return point; IntPoint absolutePoint = roundedIntPoint(m_element->renderer()->localToAbsolute(LayoutPoint(point), UseTransforms)); @@ -649,10 +649,8 @@ WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* eleme WebPluginContainerImpl::~WebPluginContainerImpl() { - if (m_touchEventRequestType != TouchEventRequestTypeNone) { - Document& document = m_element->document(); - TouchController::from(&document)->didRemoveTouchEventHandler(&document, m_element); - } + if (m_touchEventRequestType != TouchEventRequestTypeNone) + m_element->document().didRemoveTouchEventHandler(m_element); for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) m_pluginLoadObservers[i]->clearPluginContainer(); @@ -679,18 +677,18 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) if (webEvent.type == WebInputEvent::Undefined) return; - if (event->type() == eventNames().mousedownEvent) + if (event->type() == EventTypeNames::mousedown) focusPlugin(); if (m_scrollbarGroup) { // This needs to be set before the other callbacks in this scope, since // the scroll animator class might query the position in response. m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y())); - if (event->type() == eventNames().mousemoveEvent) + if (event->type() == EventTypeNames::mousemove) m_scrollbarGroup->scrollAnimator()->mouseMovedInContentArea(); - else if (event->type() == eventNames().mouseoverEvent) + else if (event->type() == EventTypeNames::mouseover) m_scrollbarGroup->scrollAnimator()->mouseEnteredContentArea(); - else if (event->type() == eventNames().mouseoutEvent) + else if (event->type() == EventTypeNames::mouseout) m_scrollbarGroup->scrollAnimator()->mouseExitedContentArea(); } @@ -704,7 +702,7 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) Page* page = parentView->frame().page(); if (!page) return; - ChromeClientImpl* chromeClient = static_cast<ChromeClientImpl*>(&page->chrome().client()); + ChromeClientImpl* chromeClient = toChromeClientImpl(page->chrome().client()); chromeClient->setCursorForPlugin(cursorInfo); } @@ -713,19 +711,19 @@ void WebPluginContainerImpl::handleDragEvent(MouseEvent* event) ASSERT(event->isDragEvent()); WebDragStatus dragStatus = WebDragStatusUnknown; - if (event->type() == eventNames().dragenterEvent) + if (event->type() == EventTypeNames::dragenter) dragStatus = WebDragStatusEnter; - else if (event->type() == eventNames().dragleaveEvent) + else if (event->type() == EventTypeNames::dragleave) dragStatus = WebDragStatusLeave; - else if (event->type() == eventNames().dragoverEvent) + else if (event->type() == EventTypeNames::dragover) dragStatus = WebDragStatusOver; - else if (event->type() == eventNames().dropEvent) + else if (event->type() == EventTypeNames::drop) dragStatus = WebDragStatusDrop; if (dragStatus == WebDragStatusUnknown) return; - ClipboardChromium* clipboard = static_cast<ClipboardChromium*>(event->dataTransfer()); + Clipboard* clipboard = event->dataTransfer(); WebDragData dragData = clipboard->dataObject(); WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation()); WebPoint dragScreenLocation(event->screenX(), event->screenY()); @@ -798,7 +796,7 @@ void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) if (webEvent.type == WebInputEvent::Undefined) return; - if (event->type() == eventNames().touchstartEvent) + if (event->type() == EventTypeNames::touchstart) focusPlugin(); WebCursorInfo cursorInfo; @@ -868,7 +866,7 @@ void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect, IntRect& clipRect, Vector<IntRect>& cutOutRects) { - windowRect = parent()->contentsToWindow(frameRect); + windowRect = toScrollView(parent())->contentsToWindow(frameRect); // Calculate a clip-rect so that we don't overlap the scrollbars, etc. clipRect = windowClipRect(); @@ -888,6 +886,7 @@ WebCore::IntRect WebPluginContainerImpl::windowClipRect() const // document().renderer() can be 0 when we receive messages from the // plugins while we are destroying a frame. + // FIXME: Can we just check m_element->document().isActive() ? if (m_element->renderer()->document().renderer()) { // Take our element and get the clip rect from the enclosing layer and // frame view. diff --git a/Source/web/WebPluginContainerImpl.h b/Source/web/WebPluginContainerImpl.h index d8e46d698..1651a1737 100644 --- a/Source/web/WebPluginContainerImpl.h +++ b/Source/web/WebPluginContainerImpl.h @@ -32,8 +32,8 @@ #define WebPluginContainerImpl_h #include "WebPluginContainer.h" -#include "core/platform/Widget.h" #include "core/plugins/PluginView.h" +#include "platform/Widget.h" #include "wtf/OwnPtr.h" #include "wtf/PassRefPtr.h" @@ -90,7 +90,7 @@ public: virtual void handleEvent(WebCore::Event*); virtual void frameRectsChanged(); virtual void setParentVisible(bool); - virtual void setParent(WebCore::ScrollView*); + virtual void setParent(WebCore::Widget*); virtual void widgetPositionsUpdated(); virtual void clipRectChanged() OVERRIDE; virtual bool isPluginContainer() const { return true; } diff --git a/Source/web/WebPluginScrollbarImpl.cpp b/Source/web/WebPluginScrollbarImpl.cpp index 551dea836..3973c6a9c 100644 --- a/Source/web/WebPluginScrollbarImpl.cpp +++ b/Source/web/WebPluginScrollbarImpl.cpp @@ -32,11 +32,11 @@ #include "WebPluginScrollbarClient.h" #include "WebViewImpl.h" #include "core/platform/ScrollAnimator.h" -#include "core/platform/ScrollTypes.h" #include "core/platform/Scrollbar.h" #include "core/platform/ScrollbarTheme.h" #include "core/platform/chromium/KeyboardCodes.h" #include "core/platform/graphics/GraphicsContext.h" +#include "platform/scroll/ScrollTypes.h" #include "public/platform/WebCanvas.h" #include "public/platform/WebRect.h" #include "public/platform/WebVector.h" diff --git a/Source/web/WebPopupMenuImpl.cpp b/Source/web/WebPopupMenuImpl.cpp index 9be33e8ae..894a2d378 100644 --- a/Source/web/WebPopupMenuImpl.cpp +++ b/Source/web/WebPopupMenuImpl.cpp @@ -38,17 +38,17 @@ #include "WebRange.h" #include "WebViewClient.h" #include "WebWidgetClient.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/platform/Cursor.h" -#include "core/platform/NotImplemented.h" -#include "core/platform/PlatformGestureEvent.h" -#include "core/platform/PlatformKeyboardEvent.h" -#include "core/platform/PlatformMouseEvent.h" -#include "core/platform/PlatformWheelEvent.h" +#include "platform/NotImplemented.h" #include "core/platform/chromium/FramelessScrollView.h" #include "core/platform/graphics/GraphicsContext.h" -#include "core/platform/graphics/IntRect.h" #include "core/platform/graphics/skia/SkiaUtils.h" +#include "platform/PlatformGestureEvent.h" +#include "platform/PlatformKeyboardEvent.h" +#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformWheelEvent.h" +#include "platform/geometry/IntRect.h" #include "public/platform/WebRect.h" #include <skia/ext/platform_canvas.h> @@ -263,6 +263,7 @@ bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent) case WebInputEvent::GestureTap: case WebInputEvent::GestureTapUnconfirmed: case WebInputEvent::GestureTapDown: + case WebInputEvent::GestureShowPress: case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureTwoFingerTap: diff --git a/Source/web/WebPopupMenuImpl.h b/Source/web/WebPopupMenuImpl.h index f2decbb1b..29df9d17b 100644 --- a/Source/web/WebPopupMenuImpl.h +++ b/Source/web/WebPopupMenuImpl.h @@ -86,6 +86,7 @@ public: virtual bool caretOrSelectionRange(size_t* location, size_t* length) OVERRIDE; virtual void setTextDirection(WebTextDirection) OVERRIDE; virtual bool isAcceleratedCompositingActive() const OVERRIDE { return false; } + virtual bool isPopupMenu() const OVERRIDE { return true; } // WebPopupMenuImpl void initialize(WebCore::FramelessScrollView* widget, const WebRect& bounds); @@ -134,6 +135,19 @@ public: WebCore::FramelessScrollView* m_widget; }; +inline WebPopupMenuImpl* toWebPopupMenuImpl(WebWidget* widget) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!widget || widget->isPopupMenu()); + return static_cast<WebPopupMenuImpl*>(widget); +} + +inline WebPopupMenuImpl* toWebPopupMenuImpl(WebCore::FramelessScrollViewClient* client) +{ + // WebPopupMenuImpl is the only implementation of FramelessScrollViewClient, + // so no need for further checking. + return static_cast<WebPopupMenuImpl*>(client); +} + } // namespace WebKit #endif diff --git a/Source/web/WebRange.cpp b/Source/web/WebRange.cpp index 67d4b2492..7af49996f 100644 --- a/Source/web/WebRange.cpp +++ b/Source/web/WebRange.cpp @@ -42,8 +42,8 @@ #include "core/dom/shadow/ShadowRoot.h" #include "core/editing/FrameSelection.h" #include "core/editing/TextIterator.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "public/platform/WebFloatQuad.h" #include "public/platform/WebString.h" #include "wtf/PassRefPtr.h" diff --git a/Source/web/WebRuntimeFeatures.cpp b/Source/web/WebRuntimeFeatures.cpp index 9f082641d..1986e58b8 100644 --- a/Source/web/WebRuntimeFeatures.cpp +++ b/Source/web/WebRuntimeFeatures.cpp @@ -76,6 +76,11 @@ bool WebRuntimeFeatures::isDatabaseEnabled() return RuntimeEnabledFeatures::databaseEnabled(); } +void WebRuntimeFeatures::enableDateExtension(bool enable) +{ + RuntimeEnabledFeatures::setDateExtensionEnabled(enable); +} + void WebRuntimeFeatures::enableDeviceMotion(bool enable) { RuntimeEnabledFeatures::setDeviceMotionEnabled(enable); @@ -120,15 +125,6 @@ bool WebRuntimeFeatures::isEncryptedMediaEnabled() return RuntimeEnabledFeatures::encryptedMediaEnabled(); } -void WebRuntimeFeatures::enableLegacyEncryptedMedia(bool enable) -{ - RuntimeEnabledFeatures::setPrefixedEncryptedMediaEnabled(enable); - // FIXME: Hack to allow MediaKeyError to be enabled for either version. - RuntimeEnabledFeatures::setEncryptedMediaAnyVersionEnabled( - RuntimeEnabledFeatures::encryptedMediaEnabled() - || RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()); -} - void WebRuntimeFeatures::enablePrefixedEncryptedMedia(bool enable) { RuntimeEnabledFeatures::setPrefixedEncryptedMediaEnabled(enable); @@ -138,11 +134,6 @@ void WebRuntimeFeatures::enablePrefixedEncryptedMedia(bool enable) || RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()); } -bool WebRuntimeFeatures::isLegacyEncryptedMediaEnabled() -{ - return RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled(); -} - bool WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() { return RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled(); @@ -158,6 +149,16 @@ bool WebRuntimeFeatures::isExperimentalCanvasFeaturesEnabled() return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); } +void WebRuntimeFeatures::enableFastTextAutosizing(bool enable) +{ + RuntimeEnabledFeatures::setFastTextAutosizingEnabled(enable); +} + +bool WebRuntimeFeatures::isFastTextAutosizingEnabled() +{ + return RuntimeEnabledFeatures::fastTextAutosizingEnabled(); +} + void WebRuntimeFeatures::enableFileSystem(bool enable) { RuntimeEnabledFeatures::setFileSystemEnabled(enable); @@ -233,6 +234,16 @@ bool WebRuntimeFeatures::isWebKitMediaSourceEnabled() return RuntimeEnabledFeatures::webKitMediaSourceEnabled(); } +void WebRuntimeFeatures::enableMediaSource(bool enable) +{ + RuntimeEnabledFeatures::setMediaSourceEnabled(enable); +} + +bool WebRuntimeFeatures::isMediaSourceEnabled() +{ + return RuntimeEnabledFeatures::mediaSourceEnabled(); +} + void WebRuntimeFeatures::enableMediaStream(bool enable) { RuntimeEnabledFeatures::setMediaStreamEnabled(enable); @@ -293,6 +304,16 @@ bool WebRuntimeFeatures::isScriptedSpeechEnabled() return RuntimeEnabledFeatures::scriptedSpeechEnabled(); } +void WebRuntimeFeatures::enableServiceWorker(bool enable) +{ + RuntimeEnabledFeatures::setServiceWorkerEnabled(enable); +} + +bool WebRuntimeFeatures::isServiceWorkerEnabled() +{ + return RuntimeEnabledFeatures::serviceWorkerEnabled(); +} + void WebRuntimeFeatures::enableSessionStorage(bool enable) { RuntimeEnabledFeatures::setSessionStorageEnabled(enable); @@ -395,6 +416,11 @@ bool WebRuntimeFeatures::isHTMLImportsEnabled() return RuntimeEnabledFeatures::htmlImportsEnabled(); } +void WebRuntimeFeatures::enableXSLT(bool enable) +{ + RuntimeEnabledFeatures::setXSLTEnabled(enable); +} + void WebRuntimeFeatures::enableEmbedderCustomElements(bool enable) { RuntimeEnabledFeatures::setEmbedderCustomElementsEnabled(enable); diff --git a/Source/web/WebScopedUserGesture.cpp b/Source/web/WebScopedUserGesture.cpp index 5bfa63b4a..3067e0c5e 100644 --- a/Source/web/WebScopedUserGesture.cpp +++ b/Source/web/WebScopedUserGesture.cpp @@ -32,7 +32,7 @@ #include "WebScopedUserGesture.h" #include "WebUserGestureToken.h" -#include "core/dom/UserGestureIndicator.h" +#include "platform/UserGestureIndicator.h" namespace WebKit { diff --git a/Source/web/WebSearchableFormData.cpp b/Source/web/WebSearchableFormData.cpp index cb375565f..1a9cfcd8c 100644 --- a/Source/web/WebSearchableFormData.cpp +++ b/Source/web/WebSearchableFormData.cpp @@ -35,7 +35,6 @@ #include "WebFormElement.h" #include "WebInputElement.h" #include "core/dom/Document.h" -#include "core/html/FormDataList.h" #include "core/html/HTMLFormControlElement.h" #include "core/html/HTMLFormElement.h" #include "core/html/HTMLInputElement.h" @@ -43,6 +42,7 @@ #include "core/html/HTMLSelectElement.h" #include "core/html/HTMLTextAreaElement.h" #include "core/platform/network/FormDataBuilder.h" +#include "core/platform/network/FormDataList.h" #include "wtf/text/TextEncoding.h" using namespace WebCore; diff --git a/Source/web/WebSelectElement.cpp b/Source/web/WebSelectElement.cpp index 405aab90d..ecfbfbbdf 100644 --- a/Source/web/WebSelectElement.cpp +++ b/Source/web/WebSelectElement.cpp @@ -61,14 +61,14 @@ WebVector<WebElement> WebSelectElement::listItems() const return items; } -WebSelectElement::WebSelectElement(const PassRefPtr<HTMLSelectElement>& elem) - : WebFormControlElement(elem) +WebSelectElement::WebSelectElement(const PassRefPtr<HTMLSelectElement>& element) + : WebFormControlElement(element) { } -WebSelectElement& WebSelectElement::operator=(const PassRefPtr<HTMLSelectElement>& elem) +WebSelectElement& WebSelectElement::operator=(const PassRefPtr<HTMLSelectElement>& element) { - m_private = elem; + m_private = element; return *this; } diff --git a/Source/web/WebSettingsImpl.cpp b/Source/web/WebSettingsImpl.cpp index b4ef0f9ee..e433f4e4c 100644 --- a/Source/web/WebSettingsImpl.cpp +++ b/Source/web/WebSettingsImpl.cpp @@ -197,6 +197,11 @@ void WebSettingsImpl::setIgnoreMainFrameOverflowHiddenQuirk(bool ignoreMainFrame m_settings->setIgnoreMainFrameOverflowHiddenQuirk(ignoreMainFrameOverflowHiddenQuirk); } +void WebSettingsImpl::setReportScreenSizeInPhysicalPixelsQuirk(bool reportScreenSizeInPhysicalPixelsQuirk) +{ + m_settings->setReportScreenSizeInPhysicalPixelsQuirk(reportScreenSizeInPhysicalPixelsQuirk); +} + void WebSettingsImpl::setSupportsMultipleWindows(bool supportsMultipleWindows) { m_settings->setSupportsMultipleWindows(supportsMultipleWindows); @@ -322,6 +327,11 @@ void WebSettingsImpl::setLocalStorageEnabled(bool enabled) m_settings->setLocalStorageEnabled(enabled); } +void WebSettingsImpl::setMainFrameClipsContent(bool enabled) +{ + m_settings->setMainFrameClipsContent(enabled); +} + void WebSettingsImpl::setEditableLinkBehaviorNeverLive() { // FIXME: If you ever need more behaviors than this, then we should probably @@ -375,21 +385,11 @@ void WebSettingsImpl::setExperimentalWebSocketEnabled(bool enabled) m_settings->setExperimentalWebSocketEnabled(enabled); } -void WebSettingsImpl::setCSSStickyPositionEnabled(bool enabled) -{ - m_settings->setCSSStickyPositionEnabled(enabled); -} - void WebSettingsImpl::setRegionBasedColumnsEnabled(bool enabled) { m_settings->setRegionBasedColumnsEnabled(enabled); } -void WebSettingsImpl::setExperimentalCSSCustomFilterEnabled(bool enabled) -{ - m_settings->setCSSCustomFilterEnabled(enabled); -} - void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled) { m_settings->setOpenGLMultisamplingEnabled(enabled); @@ -626,11 +626,6 @@ bool WebSettingsImpl::viewportEnabled() const return m_settings->viewportEnabled(); } -void WebSettingsImpl::setVisualWordMovementEnabled(bool enabled) -{ - m_settings->setVisualWordMovementEnabled(enabled); -} - void WebSettingsImpl::setShouldDisplaySubtitles(bool enabled) { m_settings->setShouldDisplaySubtitles(enabled); @@ -696,6 +691,11 @@ void WebSettingsImpl::setCompositedScrollingForFramesEnabled(bool enabled) m_settings->setCompositedScrollingForFramesEnabled(enabled); } +void WebSettingsImpl::setCompositorTouchHitTesting(bool enabled) +{ + m_settings->setCompositorTouchHitTesting(enabled); +} + void WebSettingsImpl::setSelectTrailingWhitespaceEnabled(bool enabled) { m_settings->setSelectTrailingWhitespaceEnabled(enabled); diff --git a/Source/web/WebSettingsImpl.h b/Source/web/WebSettingsImpl.h index c58b29375..c038464ec 100644 --- a/Source/web/WebSettingsImpl.h +++ b/Source/web/WebSettingsImpl.h @@ -75,6 +75,7 @@ public: virtual void setAutoZoomFocusedNodeToLegibleScale(bool); virtual void setCaretBrowsingEnabled(bool); virtual void setCompositedScrollingForFramesEnabled(bool); + virtual void setCompositorTouchHitTesting(bool); virtual void setCookieEnabled(bool); virtual void setCursiveFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); virtual void setDNSPrefetchingEnabled(bool); @@ -93,9 +94,7 @@ public: virtual void setEditingBehavior(EditingBehavior); virtual void setEnableScrollAnimator(bool); virtual void setEnableTouchAdjustment(bool); - virtual void setExperimentalCSSCustomFilterEnabled(bool); virtual void setRegionBasedColumnsEnabled(bool); - virtual void setCSSStickyPositionEnabled(bool); virtual void setExperimentalWebGLEnabled(bool); virtual void setExperimentalWebSocketEnabled(bool); virtual void setFantasyFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); @@ -115,6 +114,7 @@ public: virtual void setLoadsImagesAutomatically(bool); virtual void setLoadWithOverviewMode(bool); virtual void setLocalStorageEnabled(bool); + virtual void setMainFrameClipsContent(bool); virtual void setMediaPlaybackRequiresUserGesture(bool); virtual void setMediaFullscreenRequiresUserGesture(bool); virtual void setMemoryInfoEnabled(bool); @@ -134,6 +134,7 @@ public: virtual void setPluginsEnabled(bool); virtual void setPrivilegedWebGLExtensionsEnabled(bool); virtual void setRenderVSyncNotificationEnabled(bool); + virtual void setReportScreenSizeInPhysicalPixelsQuirk(bool); virtual void setSansSerifFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); virtual void setSelectTrailingWhitespaceEnabled(bool); virtual void setSelectionIncludesAltImageText(bool); @@ -169,13 +170,15 @@ public: virtual void setViewportEnabled(bool); virtual void setViewportMetaLayoutSizeQuirk(bool); virtual void setViewportMetaZeroValuesQuirk(bool); - virtual void setVisualWordMovementEnabled(bool); virtual void setWebAudioEnabled(bool); virtual void setWebGLErrorsToConsoleEnabled(bool); virtual void setWebSecurityEnabled(bool); virtual void setWideViewportQuirkEnabled(bool); virtual void setXSSAuditorEnabled(bool); + // FIXME: Make chromium stop calling this and delete the method. + virtual void setVisualWordMovementEnabled(bool) { } + bool showFPSCounter() const { return m_showFPSCounter; } bool showPaintRects() const { return m_showPaintRects; } bool renderVSyncNotificationEnabled() const { return m_renderVSyncNotificationEnabled; } diff --git a/Source/web/WebSharedWorkerImpl.cpp b/Source/web/WebSharedWorkerImpl.cpp index be97906b1..3730ae759 100644 --- a/Source/web/WebSharedWorkerImpl.cpp +++ b/Source/web/WebSharedWorkerImpl.cpp @@ -46,10 +46,9 @@ #include "WorkerFileSystemClient.h" #include "core/dom/CrossThreadTask.h" #include "core/dom/Document.h" -#include "core/events/MessageEvent.h" +#include "core/dom/ExecutionContext.h" #include "core/dom/MessagePortChannel.h" -#include "core/dom/ScriptExecutionContext.h" -#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h" +#include "core/events/MessageEvent.h" #include "core/html/HTMLFormElement.h" #include "core/inspector/WorkerDebuggerAgent.h" #include "core/inspector/WorkerInspectorController.h" @@ -92,6 +91,7 @@ static void initializeWebKitStaticValues() WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) : m_webView(0) + , m_mainFrame(0) , m_askedToTerminate(false) , m_client(client) , m_pauseWorkerContextOnStart(false) @@ -102,10 +102,11 @@ WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) WebSharedWorkerImpl::~WebSharedWorkerImpl() { ASSERT(m_webView); - WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); - if (webFrame) - webFrame->setClient(0); + // Detach the client before closing the view to avoid getting called back. + toWebFrameImpl(m_mainFrame)->setClient(0); + m_webView->close(); + m_mainFrame->close(); } void WebSharedWorkerImpl::stopWorkerThread() @@ -127,7 +128,8 @@ void WebSharedWorkerImpl::initializeLoader(const WebURL& url) m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled()); // FIXME: Settings information should be passed to the Worker process from Browser process when the worker // is created (similar to RenderThread::OnCreateNewView). - m_webView->initializeMainFrame(this); + m_mainFrame = WebFrame::create(this); + m_webView->setMainFrame(m_mainFrame); WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); @@ -165,7 +167,7 @@ void WebSharedWorkerImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptV message->toWireString(), channels)); } -void WebSharedWorkerImpl::postMessageTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::postMessageTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, String message, PassOwnPtr<MessagePortChannelArray> channels) @@ -174,10 +176,8 @@ void WebSharedWorkerImpl::postMessageTask(ScriptExecutionContext* context, return; WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); - for (size_t i = 0; i < webChannels.size(); ++i) { - webChannels[i] = (*channels)[i]->channel()->webChannelRelease(); - webChannels[i]->setClient(0); - } + for (size_t i = 0; i < webChannels.size(); ++i) + webChannels[i] = (*channels)[i]->webChannelRelease(); thisPtr->client()->postMessageToWorkerObject(message, webChannels); } @@ -193,7 +193,7 @@ void WebSharedWorkerImpl::postExceptionToWorkerObject(const String& errorMessage sourceURL)); } -void WebSharedWorkerImpl::postExceptionTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::postExceptionTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, const String& errorMessage, int lineNumber, const String& sourceURL) @@ -215,7 +215,7 @@ void WebSharedWorkerImpl::postConsoleMessageToWorkerObject(MessageSource source, WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this), source, level, message, lineNumber, sourceURL)); } -void WebSharedWorkerImpl::postConsoleMessageTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::postConsoleMessageTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, int source, int level, @@ -233,7 +233,7 @@ void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToPageInspectorTask, AllowCrossThreadAccess(this), message)); } -void WebSharedWorkerImpl::postMessageToPageInspectorTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& message) +void WebSharedWorkerImpl::postMessageToPageInspectorTask(ExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& message) { if (!thisPtr->client()) return; @@ -245,7 +245,7 @@ void WebSharedWorkerImpl::updateInspectorStateCookie(const WTF::String& cookie) WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&updateInspectorStateCookieTask, AllowCrossThreadAccess(this), cookie)); } -void WebSharedWorkerImpl::updateInspectorStateCookieTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& cookie) +void WebSharedWorkerImpl::updateInspectorStateCookieTask(ExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& cookie) { if (!thisPtr->client()) return; @@ -258,7 +258,7 @@ void WebSharedWorkerImpl::confirmMessageFromWorkerObject(bool hasPendingActivity hasPendingActivity)); } -void WebSharedWorkerImpl::confirmMessageTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::confirmMessageTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, bool hasPendingActivity) { @@ -274,7 +274,7 @@ void WebSharedWorkerImpl::reportPendingActivity(bool hasPendingActivity) hasPendingActivity)); } -void WebSharedWorkerImpl::reportPendingActivityTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::reportPendingActivityTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, bool hasPendingActivity) { @@ -289,7 +289,7 @@ void WebSharedWorkerImpl::workerGlobalScopeClosed() AllowCrossThreadAccess(this))); } -void WebSharedWorkerImpl::workerGlobalScopeClosedTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::workerGlobalScopeClosedTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr) { if (thisPtr->client()) @@ -304,7 +304,7 @@ void WebSharedWorkerImpl::workerGlobalScopeDestroyed() AllowCrossThreadAccess(this))); } -void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr) { if (thisPtr->client()) @@ -315,14 +315,14 @@ void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ScriptExecutionContext* // WorkerLoaderProxy ----------------------------------------------------------- -void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task) +void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) { ASSERT(m_loadingDocument->isDocument()); m_loadingDocument->postTask(task); } bool WebSharedWorkerImpl::postTaskForModeToWorkerGlobalScope( - PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) + PassOwnPtr<ExecutionContextTask> task, const String& mode) { m_workerThread->runLoop().postTaskForMode(task, mode); return true; @@ -343,20 +343,14 @@ bool WebSharedWorkerImpl::isStarted() void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel, ConnectListener* listener) { - // Convert the WebMessagePortChanel to a WebCore::MessagePortChannel. - RefPtr<PlatformMessagePortChannel> platform_channel = - PlatformMessagePortChannel::create(webChannel); - webChannel->setClient(platform_channel.get()); - OwnPtr<MessagePortChannel> channel = - MessagePortChannel::create(platform_channel); - + RefPtr<MessagePortChannel> channel = MessagePortChannel::create(webChannel); workerThread()->runLoop().postTask( createCallbackTask(&connectTask, channel.release())); if (listener) listener->connected(); } -void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPtr<MessagePortChannel> channel) +void WebSharedWorkerImpl::connectTask(ExecutionContext* context, PassRefPtr<MessagePortChannel> channel) { // Wrap the passed-in channel in a MessagePort, and send it off via a connect event. RefPtr<MessagePort> port = MessagePort::create(*context); @@ -394,7 +388,7 @@ void WebSharedWorkerImpl::pauseWorkerContextOnStart() m_pauseWorkerContextOnStart = true; } -static void resumeWorkerContextTask(ScriptExecutionContext* context, bool) +static void resumeWorkerContextTask(ExecutionContext* context, bool) { toWorkerGlobalScope(context)->workerInspectorController()->resume(); } @@ -406,7 +400,7 @@ void WebSharedWorkerImpl::resumeWorkerContext() workerThread()->runLoop().postTaskForMode(createCallbackTask(resumeWorkerContextTask, true), WorkerDebuggerAgent::debuggerTaskMode); } -static void connectToWorkerContextInspectorTask(ScriptExecutionContext* context, bool) +static void connectToWorkerContextInspectorTask(ExecutionContext* context, bool) { toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend(); } @@ -416,7 +410,7 @@ void WebSharedWorkerImpl::attachDevTools() workerThread()->runLoop().postTaskForMode(createCallbackTask(connectToWorkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); } -static void reconnectToWorkerContextInspectorTask(ScriptExecutionContext* context, const String& savedState) +static void reconnectToWorkerContextInspectorTask(ExecutionContext* context, const String& savedState) { WorkerInspectorController* ic = toWorkerGlobalScope(context)->workerInspectorController(); ic->restoreInspectorStateFromCookie(savedState); @@ -428,7 +422,7 @@ void WebSharedWorkerImpl::reattachDevTools(const WebString& savedState) workerThread()->runLoop().postTaskForMode(createCallbackTask(reconnectToWorkerContextInspectorTask, String(savedState)), WorkerDebuggerAgent::debuggerTaskMode); } -static void disconnectFromWorkerContextInspectorTask(ScriptExecutionContext* context, bool) +static void disconnectFromWorkerContextInspectorTask(ExecutionContext* context, bool) { toWorkerGlobalScope(context)->workerInspectorController()->disconnectFrontend(); } @@ -438,7 +432,7 @@ void WebSharedWorkerImpl::detachDevTools() workerThread()->runLoop().postTaskForMode(createCallbackTask(disconnectFromWorkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); } -static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, const String& message) +static void dispatchOnInspectorBackendTask(ExecutionContext* context, const String& message) { toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFromFrontend(message); } diff --git a/Source/web/WebSharedWorkerImpl.h b/Source/web/WebSharedWorkerImpl.h index 94a5c646e..f39fe47c6 100644 --- a/Source/web/WebSharedWorkerImpl.h +++ b/Source/web/WebSharedWorkerImpl.h @@ -38,7 +38,7 @@ #include "WebFrameClient.h" #include "WebSharedWorkerClient.h" #include "WebWorkerBase.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/workers/WorkerLoaderProxy.h" #include "core/workers/WorkerObjectProxy.h" #include "core/workers/WorkerThread.h" @@ -86,9 +86,9 @@ public: virtual WebView* view() const { return m_webView; } // WebCore::WorkerLoaderProxy methods: - virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>); + virtual void postTaskToLoader(PassOwnPtr<WebCore::ExecutionContextTask>); virtual bool postTaskForModeToWorkerGlobalScope( - PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode); + PassOwnPtr<WebCore::ExecutionContextTask>, const WTF::String& mode); virtual WebWorkerBase* toWebWorkerBase() OVERRIDE; // WebFrameClient methods to support resource loading thru the 'shadow page'. @@ -132,47 +132,48 @@ private: void initializeLoader(const WebURL&); - static void connectTask(WebCore::ScriptExecutionContext*, PassOwnPtr<WebCore::MessagePortChannel>); + static void connectTask(WebCore::ExecutionContext*, PassRefPtr<WebCore::MessagePortChannel>); // Tasks that are run on the main thread. static void postMessageTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr, WTF::String message, PassOwnPtr<WebCore::MessagePortChannelArray> channels); static void postExceptionTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr, const WTF::String& message, int lineNumber, const WTF::String& sourceURL); static void postConsoleMessageTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr, int source, int level, const WTF::String& message, int lineNumber, const WTF::String& sourceURL); - static void postMessageToPageInspectorTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl*, const WTF::String&); - static void updateInspectorStateCookieTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const WTF::String& cookie); + static void postMessageToPageInspectorTask(WebCore::ExecutionContext*, WebSharedWorkerImpl*, const WTF::String&); + static void updateInspectorStateCookieTask(WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr, const WTF::String& cookie); static void confirmMessageTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr, bool hasPendingActivity); static void reportPendingActivityTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr, bool hasPendingActivity); static void workerGlobalScopeClosedTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr); static void workerGlobalScopeDestroyedTask( - WebCore::ScriptExecutionContext*, + WebCore::ExecutionContext*, WebSharedWorkerImpl* thisPtr); // 'shadow page' - created to proxy loading requests from the worker. - RefPtr<WebCore::ScriptExecutionContext> m_loadingDocument; + RefPtr<WebCore::ExecutionContext> m_loadingDocument; WebView* m_webView; + WebFrame* m_mainFrame; bool m_askedToTerminate; RefPtr<WebCore::WorkerThread> m_workerThread; diff --git a/Source/web/WebSocketImpl.cpp b/Source/web/WebSocketImpl.cpp index 48c3fb9c1..a52959292 100644 --- a/Source/web/WebSocketImpl.cpp +++ b/Source/web/WebSocketImpl.cpp @@ -34,7 +34,7 @@ #include "WebDocument.h" #include "WebSocketClient.h" #include "core/dom/Document.h" -#include "core/page/ConsoleTypes.h" +#include "core/frame/ConsoleTypes.h" #include "core/page/Settings.h" #include "modules/websockets/MainThreadWebSocketChannel.h" #include "modules/websockets/WebSocketChannel.h" diff --git a/Source/web/WebSpeechGrammar.cpp b/Source/web/WebSpeechGrammar.cpp index f1bdefaa4..74f3e4542 100644 --- a/Source/web/WebSpeechGrammar.cpp +++ b/Source/web/WebSpeechGrammar.cpp @@ -54,13 +54,13 @@ WebSpeechGrammar& WebSpeechGrammar::operator=(const WTF::PassRefPtr<WebCore::Spe WebURL WebSpeechGrammar::src() const { - WEBKIT_ASSERT(m_private.get()); + BLINK_ASSERT(m_private.get()); return m_private->src(); } float WebSpeechGrammar::weight() const { - WEBKIT_ASSERT(m_private.get()); + BLINK_ASSERT(m_private.get()); return m_private->weight(); } diff --git a/Source/web/WebSpeechInputResult.cpp b/Source/web/WebSpeechInputResult.cpp index 20d7b3cbc..21da66833 100644 --- a/Source/web/WebSpeechInputResult.cpp +++ b/Source/web/WebSpeechInputResult.cpp @@ -28,7 +28,7 @@ #if ENABLE(INPUT_SPEECH) -#include "core/page/SpeechInputResult.h" +#include "core/speech/SpeechInputResult.h" #include "wtf/PassRefPtr.h" namespace WebKit { diff --git a/Source/web/WebCommon.cpp b/Source/web/WebTextAreaElement.cpp index 227d11b14..fafd94db4 100644 --- a/Source/web/WebCommon.cpp +++ b/Source/web/WebTextAreaElement.cpp @@ -29,16 +29,41 @@ */ #include "config.h" -#include "public/platform/WebCommon.h" +#include "WebTextAreaElement.h" -#include "wtf/Assertions.h" +#include "HTMLNames.h" +#include "core/html/HTMLTextAreaElement.h" +#include "public/platform/WebString.h" +#include "wtf/PassRefPtr.h" + +using namespace WebCore; namespace WebKit { -void failedAssertion(const char* file, int line, const char* function, const char* assertion) +void WebTextAreaElement::setValue(const WebString& value) +{ + unwrap<HTMLTextAreaElement>()->setValue(value); +} + +WebString WebTextAreaElement::value() const +{ + return constUnwrap<HTMLTextAreaElement>()->value(); +} + +WebTextAreaElement::WebTextAreaElement(const PassRefPtr<HTMLTextAreaElement>& element) + : WebFormControlElement(element) +{ +} + +WebTextAreaElement& WebTextAreaElement::operator=(const PassRefPtr<HTMLTextAreaElement>& element) +{ + m_private = element; + return *this; +} + +WebTextAreaElement::operator PassRefPtr<HTMLTextAreaElement>() const { - WTFReportAssertionFailure(file, line, function, assertion); - CRASH(); + return toHTMLTextAreaElement(m_private.get()); } } // namespace WebKit diff --git a/Source/web/WebTextCheckingCompletionImpl.cpp b/Source/web/WebTextCheckingCompletionImpl.cpp index 09de9b6f0..b21e1e312 100644 --- a/Source/web/WebTextCheckingCompletionImpl.cpp +++ b/Source/web/WebTextCheckingCompletionImpl.cpp @@ -33,7 +33,7 @@ #include "EditorClientImpl.h" #include "WebTextCheckingResult.h" -#include "core/platform/text/TextCheckerClient.h" +#include "platform/text/TextCheckerClient.h" #include "public/platform/WebVector.h" #include "wtf/Assertions.h" diff --git a/Source/web/WebTextCheckingCompletionImpl.h b/Source/web/WebTextCheckingCompletionImpl.h index a738dd9ab..704953830 100644 --- a/Source/web/WebTextCheckingCompletionImpl.h +++ b/Source/web/WebTextCheckingCompletionImpl.h @@ -32,7 +32,7 @@ #define WebTextCheckingCompletionImpl_h #include "WebTextCheckingCompletion.h" -#include "core/platform/text/TextChecking.h" +#include "platform/text/TextChecking.h" #include "wtf/RefPtr.h" namespace WebKit { diff --git a/Source/web/WebTextCheckingResult.cpp b/Source/web/WebTextCheckingResult.cpp index bd4f58f7c..ea5fb6fee 100644 --- a/Source/web/WebTextCheckingResult.cpp +++ b/Source/web/WebTextCheckingResult.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "WebTextCheckingResult.h" -#include "core/platform/text/TextCheckerClient.h" +#include "platform/text/TextCheckerClient.h" using namespace WebCore; @@ -40,12 +40,12 @@ namespace WebKit { WebTextCheckingResult::operator TextCheckingResult() const { TextCheckingResult result; - result.type = static_cast<TextCheckingType>(type); + result.decoration = static_cast<TextDecorationType>(decoration); result.location = location; result.length = length; result.replacement = replacement; result.hash = hash; - if (result.type == TextCheckingTypeGrammar) { + if (result.decoration == TextDecorationTypeGrammar) { GrammarDetail detail; detail.location = 0; detail.length = length; diff --git a/Source/web/WebTextRun.cpp b/Source/web/WebTextRun.cpp index 13c3d9fff..7ee2ab129 100644 --- a/Source/web/WebTextRun.cpp +++ b/Source/web/WebTextRun.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "WebTextRun.h" -#include "core/platform/graphics/TextRun.h" +#include "platform/graphics/TextRun.h" using namespace WebCore; diff --git a/Source/web/WebUserGestureIndicator.cpp b/Source/web/WebUserGestureIndicator.cpp index 1a12fb257..038b3d711 100644 --- a/Source/web/WebUserGestureIndicator.cpp +++ b/Source/web/WebUserGestureIndicator.cpp @@ -32,7 +32,7 @@ #include "WebUserGestureIndicator.h" #include "WebUserGestureToken.h" -#include "core/dom/UserGestureIndicator.h" +#include "platform/UserGestureIndicator.h" using namespace WebCore; diff --git a/Source/web/WebUserGestureToken.cpp b/Source/web/WebUserGestureToken.cpp index 43c078c2a..574b1c4ca 100644 --- a/Source/web/WebUserGestureToken.cpp +++ b/Source/web/WebUserGestureToken.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "WebUserGestureToken.h" -#include "core/dom/UserGestureIndicator.h" +#include "platform/UserGestureIndicator.h" namespace WebKit { diff --git a/Source/web/WebUserMediaRequest.cpp b/Source/web/WebUserMediaRequest.cpp index d3e5042a7..9ab252d14 100644 --- a/Source/web/WebUserMediaRequest.cpp +++ b/Source/web/WebUserMediaRequest.cpp @@ -92,8 +92,8 @@ WebMediaConstraints WebUserMediaRequest::videoConstraints() const WebSecurityOrigin WebUserMediaRequest::securityOrigin() const { - ASSERT(!isNull() && m_private->scriptExecutionContext()); - return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin()); + ASSERT(!isNull() && m_private->executionContext()); + return WebSecurityOrigin(m_private->executionContext()->securityOrigin()); } WebDocument WebUserMediaRequest::ownerDocument() const diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp index 9b391cec8..9797eba4c 100644 --- a/Source/web/WebViewImpl.cpp +++ b/Source/web/WebViewImpl.cpp @@ -31,27 +31,10 @@ #include "config.h" #include "WebViewImpl.h" -#include "public/platform/Platform.h" -#include "public/platform/WebDragData.h" -#include "public/platform/WebFloatPoint.h" -#include "public/platform/WebGestureCurve.h" -#include "public/platform/WebImage.h" -#include "public/platform/WebLayer.h" -#include "public/platform/WebLayerTreeView.h" -#include "public/platform/WebPoint.h" -#include "public/platform/WebRect.h" -#include "public/platform/WebString.h" -#include "public/platform/WebVector.h" -#include "wtf/CurrentTime.h" -#include "wtf/MainThread.h" -#include "wtf/RefPtr.h" -#include "wtf/TemporaryChange.h" -#include "wtf/Uint8ClampedArray.h" #include "AutofillPopupMenuClient.h" #include "CSSValueKeywords.h" #include "CompositionUnderlineVectorBuilder.h" #include "ContextFeaturesClientImpl.h" -#include "DeviceOrientationClientProxy.h" #include "FullscreenController.h" #include "GeolocationClientProxy.h" #include "GraphicsLayerFactoryChromium.h" @@ -95,15 +78,15 @@ #include "core/css/resolver/StyleResolver.h" #include "core/dom/Document.h" #include "core/dom/DocumentMarkerController.h" -#include "core/events/KeyboardEvent.h" #include "core/dom/NodeRenderStyle.h" #include "core/dom/Text.h" #include "core/dom/WheelController.h" -#include "core/events/WheelEvent.h" #include "core/editing/Editor.h" #include "core/editing/FrameSelection.h" #include "core/editing/InputMethodController.h" #include "core/editing/TextIterator.h" +#include "core/events/KeyboardEvent.h" +#include "core/events/WheelEvent.h" #include "core/html/HTMLInputElement.h" #include "core/html/HTMLMediaElement.h" #include "core/html/HTMLTextAreaElement.h" @@ -119,9 +102,9 @@ #include "core/page/DragSession.h" #include "core/page/EventHandler.h" #include "core/page/FocusController.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include "core/page/FrameTree.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/PageGroup.h" #include "core/page/PageGroupLoadDeferrer.h" @@ -134,16 +117,9 @@ #include "core/platform/Cursor.h" #include "core/platform/DragData.h" #include "core/platform/MIMETypeRegistry.h" -#include "core/platform/NotImplemented.h" -#include "core/platform/PlatformGestureEvent.h" -#include "core/platform/PlatformKeyboardEvent.h" -#include "core/platform/PlatformMouseEvent.h" -#include "core/platform/PlatformWheelEvent.h" #include "core/platform/PopupMenuClient.h" -#include "core/platform/Timer.h" #include "core/platform/chromium/ChromiumDataObject.h" #include "core/platform/chromium/KeyboardCodes.h" -#include "core/platform/chromium/TraceEvent.h" #include "core/platform/chromium/support/WebActiveGestureAnimation.h" #include "core/platform/graphics/Color.h" #include "core/platform/graphics/ColorSpace.h" @@ -161,18 +137,41 @@ #include "core/rendering/RenderWidget.h" #include "core/rendering/TextAutosizer.h" #include "modules/geolocation/GeolocationController.h" +#include "painting/ContinuousPainter.h" +#include "platform/NotImplemented.h" +#include "platform/PlatformGestureEvent.h" +#include "platform/PlatformKeyboardEvent.h" +#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformWheelEvent.h" +#include "platform/Timer.h" +#include "platform/TraceEvent.h" +#include "public/platform/Platform.h" +#include "public/platform/WebDragData.h" +#include "public/platform/WebFloatPoint.h" +#include "public/platform/WebGestureCurve.h" +#include "public/platform/WebImage.h" +#include "public/platform/WebLayer.h" +#include "public/platform/WebLayerTreeView.h" +#include "public/platform/WebPoint.h" +#include "public/platform/WebRect.h" +#include "public/platform/WebString.h" +#include "public/platform/WebVector.h" #include "weborigin/SchemeRegistry.h" #include "weborigin/SecurityOrigin.h" #include "weborigin/SecurityPolicy.h" -#include "painting/ContinuousPainter.h" +#include "wtf/CurrentTime.h" +#include "wtf/MainThread.h" +#include "wtf/RefPtr.h" +#include "wtf/TemporaryChange.h" +#include "wtf/Uint8ClampedArray.h" -#if ENABLE(DEFAULT_RENDER_THEME) +#if USE(DEFAULT_RENDER_THEME) #include "core/platform/chromium/PlatformThemeChromiumDefault.h" #include "core/rendering/RenderThemeChromiumDefault.h" #endif #if OS(WIN) -#if !ENABLE(DEFAULT_RENDER_THEME) +#if !USE(DEFAULT_RENDER_THEME) #include "core/rendering/RenderThemeChromiumWin.h" #endif #else @@ -271,6 +270,12 @@ static int webInputEventKeyStateToPlatformEventKeyState(int webInputEventKeyStat WebView* WebView::create(WebViewClient* client) { // Pass the WebViewImpl's self-reference to the caller. + return WebViewImpl::create(client); +} + +WebViewImpl* WebViewImpl::create(WebViewClient* client) +{ + // Pass the WebViewImpl's self-reference to the caller. return adoptRef(new WebViewImpl(client)).leakRef(); } @@ -314,18 +319,27 @@ void WebView::didExitModalLoop() pageGroupLoadDeferrerStack().removeLast(); } -void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) +void WebViewImpl::setMainFrame(WebFrame* frame) { - // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame - // and releases that reference once the corresponding Frame is destroyed. - RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient); - - frame->initializeAsMainFrame(page()); + // NOTE: The WebFrameImpl takes a reference to itself within + // initializeAsMainFrame() and releases that reference once the + // corresponding Frame is destroyed. + toWebFrameImpl(frame)->initializeAsMainFrame(page()); } -void WebViewImpl::initializeHelperPluginFrame(WebFrameClient* client) +void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) { - RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client); + // NOTE: Previously, WebViewImpl was responsible for allocating its own + // mainframe. This code is for supporting clients that have yet to move + // to setMainFrame(). Though the setMainFrame() accepts a raw pointer, it + // implicitly takes a refcount on the frame. Dropping our RefPtr here + // will effectively pass ownership to m_page. New users of WebViewImpl + // should call WebFrameImpl::create() to construct their own mainframe, + // pass it into WebViewImpl::setMainFrame(), keep a pointer to the + // mainframe, and call WebFrameImpl::close() on it when closing the + // WebViewImpl. + RefPtr<WebFrameImpl> frame = adoptRef(WebFrameImpl::create(frameClient)); + setMainFrame(frame.get()); } void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) @@ -399,6 +413,8 @@ WebViewImpl::WebViewImpl(WebViewClient* client) , m_contextMenuAllowed(false) , m_doingDragAndDrop(false) , m_ignoreInputEvents(false) + , m_compositorDeviceScaleFactorOverride(0) + , m_rootLayerScale(1) , m_suppressNextKeypressEvent(false) , m_imeAcceptEvents(true) , m_operationsAllowed(WebDragOperationNone) @@ -420,7 +436,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client) , m_speechInputClient(SpeechInputClientImpl::create(client)) #endif , m_speechRecognitionClient(SpeechRecognitionClientProxy::create(client ? client->speechRecognizer() : 0)) - , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))) , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0))) , m_userMediaClientImpl(this) , m_midiClientProxy(adoptPtr(new MIDIClientProxy(client ? client->webMIDIClient() : 0))) @@ -459,7 +474,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client) #endif provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get()); - provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get()); provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get()); m_geolocationClientProxy->setController(GeolocationController::from(m_page.get())); @@ -469,9 +483,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client) m_page->setGroupType(Page::SharedPageGroup); - unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout; - m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones)); - if (m_client) { setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor); setVisibilityState(m_client->visibilityState(), true); @@ -658,8 +669,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) bool eventSwallowed = false; bool eventCancelled = false; // for disambiguation + // TODO - once chrome passes GestureShowPress and GestureTapDown events correctly, + // don't retype tap down events. See crbug.com/302752. + WebInputEvent::Type eventType = event.type; + if (eventType == WebInputEvent::GestureTapDown) + eventType = WebInputEvent::GestureShowPress; + // Special handling for slow-path fling gestures, which have no PlatformGestureEvent equivalent. - switch (event.type) { + switch (eventType) { case WebInputEvent::GestureFlingStart: { if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures()) { m_client->didHandleGestureEvent(event, eventCancelled); @@ -696,10 +713,10 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) // Handle link highlighting outside the main switch to avoid getting lost in the // complicated set of cases handled below. - switch (event.type) { - case WebInputEvent::GestureTapDown: + switch (eventType) { + case WebInputEvent::GestureShowPress: // Queue a highlight animation, then hand off to regular handler. -#if OS(LINUX) +#if OS(LINUX) || OS(ANDROID) if (settingsImpl()->gestureTapHighlightEnabled()) enableTapHighlightAtPoint(platformEvent); #endif @@ -714,7 +731,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) break; } - switch (event.type) { + switch (eventType) { case WebInputEvent::GestureTap: { m_client->cancelScheduledContentIntents(); if (detectContentOnTouch(platformEvent.position())) { @@ -780,7 +797,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) break; } - case WebInputEvent::GestureTapDown: { + case WebInputEvent::GestureShowPress: { m_client->cancelScheduledContentIntents(); eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); break; @@ -1229,36 +1246,37 @@ Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent) HitTestResult result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::DisallowShadowContent); bestTouchNode = result.targetNode(); - Node* originalTouchNode = bestTouchNode; + Node* firstUncontainedNode = 0; - // Check if we're in the subtree of a node with a hand cursor, our heuristic to choose the appropriate target. - while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame())) + // We might hit something like an image map that has no renderer on it + // Walk up the tree until we have a node with an attached renderer + while (bestTouchNode && !bestTouchNode->renderer()) bestTouchNode = bestTouchNode->parentNode(); - if (!bestTouchNode) - return 0; - // FIXME: http://crbug.com/289764 - Instead of stopping early on isContainedInParentBoundingBox, LinkHighlight // should calculate the appropriate rects (currently it just uses the linebox) - // FIXME: Remove check for isLayerModelObject once LinkHighlight is fixed to use RenderObject - // We now walk up the tree as before except we stop early if the node isn't contained in its parent's rect. - bestTouchNode = originalTouchNode; + // Check if we're in the subtree of a node with a hand cursor + // this is the heuristic we use to determine if we show a highlight on tap + while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame())) { + if (!firstUncontainedNode && !bestTouchNode->renderer()->isContainedInParentBoundingBox()) + firstUncontainedNode = bestTouchNode; - // FIXME: Refactor this to use renderer rather than node. All these loops can probably be merged into something cleaner - while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame()) - && bestTouchNode->renderer() && (!bestTouchNode->renderer()->isLayerModelObject() || bestTouchNode->renderer()->isContainedInParentBoundingBox())) bestTouchNode = bestTouchNode->parentNode(); + } + + if (!bestTouchNode) + return 0; + + if (firstUncontainedNode) + return firstUncontainedNode; // We should pick the largest enclosing node with hand cursor set. - while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), false, m_page->mainFrame()) - && bestTouchNode->renderer() && (!bestTouchNode->renderer()->isLayerModelObject() || bestTouchNode->renderer()->isContainedInParentBoundingBox())) + while (bestTouchNode->parentNode() + && invokesHandCursor(bestTouchNode->parentNode(), false, m_page->mainFrame()) + && bestTouchNode->renderer()->isContainedInParentBoundingBox()) bestTouchNode = bestTouchNode->parentNode(); - // FIXME: Remove check for isLayerModelObject once LinkHighlight is fixed to use RenderObject - if (!bestTouchNode || !bestTouchNode->renderer() || !bestTouchNode->renderer()->isLayerModelObject()) - return 0; - return bestTouchNode; } @@ -1564,7 +1582,7 @@ PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); ASSERT(popupWidget); - m_pagePopup = static_cast<WebPagePopupImpl*>(popupWidget); + m_pagePopup = toWebPagePopupImpl(popupWidget); if (!m_pagePopup->initialize(this, client, originBoundsInRootView)) { m_pagePopup->closePopup(); m_pagePopup = 0; @@ -1575,7 +1593,7 @@ PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or void WebViewImpl::closePagePopup(PagePopup* popup) { ASSERT(popup); - WebPagePopupImpl* popupImpl = static_cast<WebPagePopupImpl*>(popup); + WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); ASSERT(m_pagePopup.get() == popupImpl); if (m_pagePopup.get() != popupImpl) return; @@ -1595,7 +1613,7 @@ WebHelperPluginImpl* WebViewImpl::createHelperPlugin(const String& pluginType, c { WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypeHelperPlugin); ASSERT(popupWidget); - WebHelperPluginImpl* helperPlugin = static_cast<WebHelperPluginImpl*>(popupWidget); + WebHelperPluginImpl* helperPlugin = toWebHelperPluginImpl(popupWidget); if (!helperPlugin->initialize(pluginType, hostDocument, this)) { helperPlugin->closeHelperPlugin(); @@ -1707,18 +1725,16 @@ void WebViewImpl::resize(const WebSize& newSize) } // Set the fixed layout size from the viewport constraints before resizing. - updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()->viewportArguments()); + updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()->viewportDescription()); WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); if (agentPrivate) agentPrivate->webViewResized(newSize); - if (!agentPrivate || !agentPrivate->metricsOverridden()) { - WebFrameImpl* webFrame = mainFrameImpl(); - if (webFrame->frameView()) { - webFrame->frameView()->resize(m_size); - if (m_pinchViewports) - m_pinchViewports->setViewportSize(m_size); - } + WebFrameImpl* webFrame = mainFrameImpl(); + if (webFrame->frameView()) { + webFrame->frameView()->resize(m_size); + if (m_pinchViewports) + m_pinchViewports->setViewportSize(m_size); } if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { @@ -1795,8 +1811,9 @@ void WebViewImpl::animate(double monotonicFrameBeginTime) m_layerTreeView->didStopFlinging(); PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd, - m_positionOnFlingStart, m_globalPositionOnFlingStart, 0, 0, 0, - false, false, false, false); + m_positionOnFlingStart, m_globalPositionOnFlingStart, + IntSize(), 0, false, false, false, false, + 0, 0, 0, 0); mainFrameImpl()->frame()->eventHandler()->handleGestureScrollEnd(endScrollEvent); } @@ -1979,16 +1996,16 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) AtomicString eventType; switch (inputEvent.type) { case WebInputEvent::MouseMove: - eventType = eventNames().mousemoveEvent; + eventType = EventTypeNames::mousemove; break; case WebInputEvent::MouseLeave: - eventType = eventNames().mouseoutEvent; + eventType = EventTypeNames::mouseout; break; case WebInputEvent::MouseDown: - eventType = eventNames().mousedownEvent; + eventType = EventTypeNames::mousedown; break; case WebInputEvent::MouseUp: - eventType = eventNames().mouseupEvent; + eventType = EventTypeNames::mouseup; break; default: ASSERT_NOT_REACHED(); @@ -2912,7 +2929,7 @@ void WebViewImpl::setDeviceScaleFactor(float scaleFactor) page()->setDeviceScaleFactor(scaleFactor); if (m_layerTreeView) - m_layerTreeView->setDeviceScaleFactor(scaleFactor); + updateLayerTreeDeviceScaleFactor(); } bool WebViewImpl::isFixedLayoutModeEnabled() const @@ -3009,7 +3026,7 @@ void WebViewImpl::refreshPageScaleFactorAfterLayout() return; FrameView* view = page()->mainFrame()->view(); - updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()->viewportArguments()); + updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()->viewportDescription()); m_pageScaleConstraintsSet.computeFinalConstraints(); if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { @@ -3034,20 +3051,20 @@ void WebViewImpl::refreshPageScaleFactorAfterLayout() view->layout(); } -void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments& arguments) +void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportDescription& description) { if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height) return; - ViewportArguments adjustedArguments = arguments; - if (settingsImpl()->viewportMetaLayoutSizeQuirk() && adjustedArguments.type == ViewportArguments::ViewportMeta) { - if (adjustedArguments.maxWidth.type() == ExtendToZoom) - adjustedArguments.maxWidth = Length(); // auto - adjustedArguments.minWidth = adjustedArguments.maxWidth; - adjustedArguments.minHeight = adjustedArguments.maxHeight; + ViewportDescription adjustedDescription = description; + if (settingsImpl()->viewportMetaLayoutSizeQuirk() && adjustedDescription.type == ViewportDescription::ViewportMeta) { + if (adjustedDescription.maxWidth.type() == ExtendToZoom) + adjustedDescription.maxWidth = Length(); // auto + adjustedDescription.minWidth = adjustedDescription.maxWidth; + adjustedDescription.minHeight = adjustedDescription.maxHeight; } - m_pageScaleConstraintsSet.updatePageDefinedConstraints(adjustedArguments, m_size); - m_pageScaleConstraintsSet.adjustForAndroidWebViewQuirks(adjustedArguments, m_size, page()->settings().layoutFallbackWidth(), deviceScaleFactor(), settingsImpl()->supportDeprecatedTargetDensityDPI(), page()->settings().wideViewportQuirkEnabled(), page()->settings().useWideViewport(), page()->settings().loadWithOverviewMode()); + m_pageScaleConstraintsSet.updatePageDefinedConstraints(adjustedDescription, m_size); + m_pageScaleConstraintsSet.adjustForAndroidWebViewQuirks(adjustedDescription, m_size, page()->settings().layoutFallbackWidth(), deviceScaleFactor(), settingsImpl()->supportDeprecatedTargetDensityDPI(), page()->settings().wideViewportQuirkEnabled(), page()->settings().useWideViewport(), page()->settings().loadWithOverviewMode()); WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedConstraints().layoutSize); @@ -3469,6 +3486,21 @@ void WebViewImpl::setInspectorSetting(const WebString& key, client()->didUpdateInspectorSetting(key, value); } +void WebViewImpl::setCompositorDeviceScaleFactorOverride(float deviceScaleFactor) +{ + m_compositorDeviceScaleFactorOverride = deviceScaleFactor; + if (page() && m_layerTreeView) + updateLayerTreeDeviceScaleFactor(); +} + +void WebViewImpl::setRootLayerScaleTransform(float rootLayerScale) +{ + m_rootLayerScale = rootLayerScale; + if (mainFrameImpl()) + mainFrameImpl()->setInputEventsScaleFactorForEmulation(m_rootLayerScale); + updateRootLayerTransform(); +} + WebDevToolsAgent* WebViewImpl::devToolsAgent() { return m_devToolsAgent.get(); @@ -3626,7 +3658,7 @@ void WebViewImpl::setWindowFeatures(const WebWindowFeatures& features) void WebViewImpl::setScrollbarColors(unsigned inactiveColor, unsigned activeColor, unsigned trackColor) { -#if ENABLE(DEFAULT_RENDER_THEME) +#if USE(DEFAULT_RENDER_THEME) PlatformThemeChromiumDefault::setScrollbarColors(inactiveColor, activeColor, trackColor); #endif } @@ -3635,36 +3667,25 @@ void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor, unsigned activeForegroundColor, unsigned inactiveBackgroundColor, unsigned inactiveForegroundColor) { -#if ENABLE(DEFAULT_RENDER_THEME) +#if USE(DEFAULT_RENDER_THEME) RenderThemeChromiumDefault::setSelectionColors(activeBackgroundColor, activeForegroundColor, inactiveBackgroundColor, inactiveForegroundColor); RenderTheme::theme().platformColorsDidChange(); #endif } -void WebView::addUserStyleSheet(const WebString& sourceCode, - const WebVector<WebString>& patternsIn, - WebView::UserContentInjectIn injectIn, - WebView::UserStyleInjectionTime injectionTime) +void WebView::injectStyleSheet(const WebString& sourceCode, const WebVector<WebString>& patternsIn, WebView::StyleInjectionTarget injectIn) { Vector<String> patterns; for (size_t i = 0; i < patternsIn.size(); ++i) patterns.append(patternsIn[i]); PageGroup* pageGroup = PageGroup::sharedGroup(); - - // FIXME: Current callers always want the level to be "author". It probably makes sense to let - // callers specify this though, since in other cases the caller will probably want "user" level. - // - // FIXME: It would be nice to populate the URL correctly, instead of passing an empty URL. - pageGroup->addUserStyleSheet(sourceCode, WebURL(), patterns, Vector<String>(), - static_cast<UserContentInjectedFrames>(injectIn), - UserStyleAuthorLevel, - static_cast<WebCore::UserStyleInjectionTime>(injectionTime)); + pageGroup->injectStyleSheet(sourceCode, patterns, static_cast<WebCore::StyleInjectionTarget>(injectIn)); } -void WebView::removeAllUserContent() +void WebView::removeInjectedStyleSheets() { - PageGroup::sharedGroup()->removeAllUserContent(); + PageGroup::sharedGroup()->removeInjectedStyleSheets(); } void WebViewImpl::didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPage) @@ -3803,7 +3824,7 @@ void WebViewImpl::refreshAutofillPopup() WebRect newWidgetRect = m_autofillPopup->refresh(focusedElement()->pixelSnappedBoundingBox()); // Let's resize the backing window if necessary. - WebPopupMenuImpl* popupMenu = static_cast<WebPopupMenuImpl*>(m_autofillPopup->client()); + WebPopupMenuImpl* popupMenu = toWebPopupMenuImpl(m_autofillPopup->client()); if (popupMenu && popupMenu->client()->windowRect() != newWidgetRect) popupMenu->client()->setWindowRect(newWidgetRect); } @@ -3872,6 +3893,8 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) setIsAcceleratedCompositingActive(layer); + updateRootLayerTransform(); + if (m_layerTreeView) { if (m_rootLayer) { m_layerTreeView->setRootLayer(*m_rootLayer); @@ -3994,7 +4017,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) bool visible = page()->visibilityState() == PageVisibilityStateVisible; m_layerTreeView->setVisible(visible); - m_layerTreeView->setDeviceScaleFactor(page()->deviceScaleFactor()); + updateLayerTreeDeviceScaleFactor(); m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor()); m_layerTreeView->setBackgroundColor(backgroundColor()); m_layerTreeView->setHasTransparentBackground(isTransparent()); @@ -4079,6 +4102,24 @@ void WebViewImpl::updateLayerTreeViewport() m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor()); } +void WebViewImpl::updateLayerTreeDeviceScaleFactor() +{ + ASSERT(page()); + ASSERT(m_layerTreeView); + + float deviceScaleFactor = m_compositorDeviceScaleFactorOverride ? m_compositorDeviceScaleFactorOverride : page()->deviceScaleFactor(); + m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor); +} + +void WebViewImpl::updateRootLayerTransform() +{ + if (m_rootGraphicsLayer) { + WebCore::TransformationMatrix transform; + transform = transform.scale(m_rootLayerScale); + m_rootGraphicsLayer->setChildrenTransform(transform); + } +} + void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex) { if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestionsCount()) @@ -4154,13 +4195,13 @@ void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) AtomicString eventType; switch (event.type) { case WebInputEvent::MouseDown: - eventType = eventNames().mousedownEvent; + eventType = EventTypeNames::mousedown; break; case WebInputEvent::MouseUp: - eventType = eventNames().mouseupEvent; + eventType = EventTypeNames::mouseup; break; case WebInputEvent::MouseMove: - eventType = eventNames().mousemoveEvent; + eventType = EventTypeNames::mousemove; break; default: ASSERT_NOT_REACHED(); diff --git a/Source/web/WebViewImpl.h b/Source/web/WebViewImpl.h index 7e96a978d..1feaf7f85 100644 --- a/Source/web/WebViewImpl.h +++ b/Source/web/WebViewImpl.h @@ -39,19 +39,19 @@ #include "InspectorClientImpl.h" #include "NotificationPresenterImpl.h" #include "PageOverlayList.h" +#include "PageScaleConstraintsSet.h" #include "PageWidgetDelegate.h" #include "UserMediaClientImpl.h" #include "WebInputEvent.h" #include "WebNavigationPolicy.h" #include "WebView.h" #include "core/page/PagePopupDriver.h" -#include "core/page/PageScaleConstraintsSet.h" -#include "core/platform/Timer.h" -#include "core/platform/graphics/FloatSize.h" #include "core/platform/graphics/GraphicsContext3D.h" #include "core/platform/graphics/GraphicsLayer.h" -#include "core/platform/graphics/IntPoint.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/Timer.h" +#include "platform/geometry/FloatSize.h" +#include "platform/geometry/IntPoint.h" +#include "platform/geometry/IntRect.h" #include "public/platform/WebFloatQuad.h" #include "public/platform/WebGestureCurveTarget.h" #include "public/platform/WebLayer.h" @@ -92,7 +92,6 @@ class AutocompletePopupMenuClient; class AutofillPopupMenuClient; class ContextFeaturesClientImpl; class ContextMenuClientImpl; -class DeviceOrientationClientProxy; class GeolocationClientProxy; class LinkHighlight; class MIDIClientProxy; @@ -128,6 +127,7 @@ class WebViewImpl : public WebView , public WebCore::PagePopupDriver , public PageWidgetEventHandler { public: + static WebViewImpl* create(WebViewClient*); // WebWidget methods: virtual void close(); @@ -181,8 +181,8 @@ public: virtual void didExitCompositingMode(); // WebView methods: + virtual void setMainFrame(WebFrame*); virtual void initializeMainFrame(WebFrameClient*); - virtual void initializeHelperPluginFrame(WebFrameClient*); virtual void setAutofillClient(WebAutofillClient*); virtual void setDevToolsAgentClient(WebDevToolsAgentClient*); virtual void setPermissionClient(WebPermissionClient*); @@ -289,6 +289,8 @@ public: virtual bool inspectorSetting(const WebString& key, WebString* value) const; virtual void setInspectorSetting(const WebString& key, const WebString& value); + virtual void setCompositorDeviceScaleFactorOverride(float); + virtual void setRootLayerScaleTransform(float); virtual WebDevToolsAgent* devToolsAgent(); virtual WebAXObject accessibilityObject(); virtual void applyAutofillSuggestions( @@ -444,7 +446,7 @@ public: return m_maxAutoSize; } - void updatePageDefinedPageScaleConstraints(const WebCore::ViewportArguments&); + void updatePageDefinedPageScaleConstraints(const WebCore::ViewportDescription&); // Start a system drag and drop operation. void startDragging( @@ -584,7 +586,7 @@ private: DragOver }; - WebViewImpl(WebViewClient*); + explicit WebViewImpl(WebViewClient*); virtual ~WebViewImpl(); WebTextInputType textInputType(); @@ -628,6 +630,8 @@ private: void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); void reallocateRenderer(); void updateLayerTreeViewport(); + void updateRootLayerTransform(); + void updateLayerTreeDeviceScaleFactor(); // Helper function: Widens the width of |source| by the specified margins // while keeping it smaller than page width. @@ -704,7 +708,7 @@ private: double m_maximumZoomLevel; - WebCore::PageScaleConstraintsSet m_pageScaleConstraintsSet; + PageScaleConstraintsSet m_pageScaleConstraintsSet; // Saved page scale state. float m_savedPageScaleFactor; // 0 means that no page scale factor is saved. @@ -727,6 +731,9 @@ private: bool m_ignoreInputEvents; + float m_compositorDeviceScaleFactorOverride; + float m_rootLayerScale; + // Webkit expects keyPress events to be suppressed if the associated keyDown // event was handled. Safari implements this behavior by peeking out the // associated WM_CHAR event if the keydown was handled. We emulate @@ -801,7 +808,6 @@ private: #endif OwnPtr<SpeechRecognitionClientProxy> m_speechRecognitionClient; - OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy; OwnPtr<GeolocationClientProxy> m_geolocationClientProxy; UserMediaClientImpl m_userMediaClientImpl; diff --git a/Source/web/WebWorkerBase.cpp b/Source/web/WebWorkerBase.cpp index 115b8383a..633d135a6 100644 --- a/Source/web/WebWorkerBase.cpp +++ b/Source/web/WebWorkerBase.cpp @@ -44,14 +44,14 @@ namespace WebKit { static void invokeTaskMethod(void* param) { - ScriptExecutionContext::Task* task = - static_cast<ScriptExecutionContext::Task*>(param); + ExecutionContextTask* task = + static_cast<ExecutionContextTask*>(param); task->performTask(0); delete task; } -void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task) +void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ExecutionContextTask> task) { callOnMainThread(invokeTaskMethod, task.leakPtr()); } diff --git a/Source/web/WebWorkerBase.h b/Source/web/WebWorkerBase.h index 918861ecb..6ee9391b3 100644 --- a/Source/web/WebWorkerBase.h +++ b/Source/web/WebWorkerBase.h @@ -32,7 +32,7 @@ #define WebWorkerBase_h #include "WebCommonWorkerClient.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/workers/WorkerLoaderProxy.h" #include "core/workers/WorkerObjectProxy.h" #include "wtf/PassOwnPtr.h" @@ -53,7 +53,7 @@ public: virtual WebView* view() const = 0; // Executes the given task on the main thread. - static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>); + static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ExecutionContextTask>); }; } // namespace WebKit diff --git a/Source/web/WebWorkerClientImpl.cpp b/Source/web/WebWorkerClientImpl.cpp index 3457ca678..0f00a1545 100644 --- a/Source/web/WebWorkerClientImpl.cpp +++ b/Source/web/WebWorkerClientImpl.cpp @@ -32,7 +32,7 @@ #include "WebWorkerClientImpl.h" #include "core/dom/Document.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/inspector/ScriptCallStack.h" #include "core/workers/Worker.h" #include "core/workers/WorkerClients.h" @@ -56,8 +56,8 @@ namespace WebKit { // static WorkerGlobalScopeProxy* WebWorkerClientImpl::createWorkerGlobalScopeProxy(Worker* worker) { - if (worker->scriptExecutionContext()->isDocument()) { - Document* document = toDocument(worker->scriptExecutionContext()); + if (worker->executionContext()->isDocument()) { + Document* document = toDocument(worker->executionContext()); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); OwnPtr<WorkerClients> workerClients = WorkerClients::create(); provideLocalFileSystemToWorker(workerClients.get(), WorkerFileSystemClient::create()); diff --git a/Source/web/WebWorkerClientImpl.h b/Source/web/WebWorkerClientImpl.h index dd1f3d56d..754af9186 100644 --- a/Source/web/WebWorkerClientImpl.h +++ b/Source/web/WebWorkerClientImpl.h @@ -31,7 +31,7 @@ #ifndef WebWorkerClientImpl_h #define WebWorkerClientImpl_h -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/workers/WorkerGlobalScopeProxy.h" #include "core/workers/WorkerLoaderProxy.h" #include "core/workers/WorkerMessagingProxy.h" diff --git a/Source/web/WebWorkerRunLoop.cpp b/Source/web/WebWorkerRunLoop.cpp index d68e60f3f..fd9d37992 100644 --- a/Source/web/WebWorkerRunLoop.cpp +++ b/Source/web/WebWorkerRunLoop.cpp @@ -33,14 +33,14 @@ namespace WebKit { namespace { -class TaskForwarder : public ScriptExecutionContext::Task { +class TaskForwarder : public ExecutionContextTask { public: static PassOwnPtr<TaskForwarder> create(PassOwnPtr<WebWorkerRunLoop::Task> task) { return adoptPtr(new TaskForwarder(task)); } - virtual void performTask(ScriptExecutionContext*) + virtual void performTask(ExecutionContext*) { m_task->Run(); } diff --git a/Source/web/WorkerAllowMainThreadBridgeBase.cpp b/Source/web/WorkerAllowMainThreadBridgeBase.cpp index cfadb8ae1..a2e674884 100644 --- a/Source/web/WorkerAllowMainThreadBridgeBase.cpp +++ b/Source/web/WorkerAllowMainThreadBridgeBase.cpp @@ -44,6 +44,8 @@ public: return adoptPtr(new WorkerGlobalScopeObserver(context, bridge)); } + virtual ~WorkerGlobalScopeObserver() { } + // WorkerGlobalScope::Observer method. virtual void notifyStop() { @@ -68,7 +70,7 @@ namespace WebKit { WorkerAllowMainThreadBridgeBase::WorkerAllowMainThreadBridgeBase(WebCore::WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase) : m_webWorkerBase(webWorkerBase) - , m_workerGlobalScopeObserver(WorkerGlobalScopeObserver::create(workerGlobalScope, this).leakPtr()) + , m_workerGlobalScopeObserver(WorkerGlobalScopeObserver::create(workerGlobalScope, this)) { } @@ -79,7 +81,7 @@ void WorkerAllowMainThreadBridgeBase::postTaskToMainThread(PassOwnPtr<AllowParam } // static -void WorkerAllowMainThreadBridgeBase::allowTask(WebCore::ScriptExecutionContext*, PassOwnPtr<AllowParams> params, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge) +void WorkerAllowMainThreadBridgeBase::allowTask(WebCore::ExecutionContext*, PassOwnPtr<AllowParams> params, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge) { ASSERT(isMainThread()); if (!bridge) @@ -96,7 +98,7 @@ void WorkerAllowMainThreadBridgeBase::allowTask(WebCore::ScriptExecutionContext* } // static -void WorkerAllowMainThreadBridgeBase::didComplete(WebCore::ScriptExecutionContext* context, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge, bool result) +void WorkerAllowMainThreadBridgeBase::didComplete(WebCore::ExecutionContext* context, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge, bool result) { bridge->m_result = result; } diff --git a/Source/web/WorkerAllowMainThreadBridgeBase.h b/Source/web/WorkerAllowMainThreadBridgeBase.h index 3c9cd5a52..a89e870da 100644 --- a/Source/web/WorkerAllowMainThreadBridgeBase.h +++ b/Source/web/WorkerAllowMainThreadBridgeBase.h @@ -81,12 +81,12 @@ protected: void postTaskToMainThread(PassOwnPtr<AllowParams>); private: - static void allowTask(WebCore::ScriptExecutionContext*, PassOwnPtr<AllowParams>, PassRefPtr<WorkerAllowMainThreadBridgeBase>); - static void didComplete(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerAllowMainThreadBridgeBase>, bool); + static void allowTask(WebCore::ExecutionContext*, PassOwnPtr<AllowParams>, PassRefPtr<WorkerAllowMainThreadBridgeBase>); + static void didComplete(WebCore::ExecutionContext*, PassRefPtr<WorkerAllowMainThreadBridgeBase>, bool); Mutex m_mutex; WebWorkerBase* m_webWorkerBase; - WebCore::WorkerGlobalScope::Observer* m_workerGlobalScopeObserver; + OwnPtr<WebCore::WorkerGlobalScope::Observer> m_workerGlobalScopeObserver; bool m_result; }; diff --git a/Source/web/WorkerFileSystemClient.cpp b/Source/web/WorkerFileSystemClient.cpp index afdbf17cb..0ab0c7de8 100644 --- a/Source/web/WorkerFileSystemClient.cpp +++ b/Source/web/WorkerFileSystemClient.cpp @@ -33,7 +33,7 @@ #include "WebWorkerBase.h" #include "WorkerAllowMainThreadBridgeBase.h" -#include "core/dom/ScriptExecutionContext.h" +#include "core/dom/ExecutionContext.h" #include "core/platform/AsyncFileSystemCallbacks.h" #include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerThread.h" @@ -85,7 +85,7 @@ WorkerFileSystemClient::~WorkerFileSystemClient() { } -bool WorkerFileSystemClient::allowFileSystem(ScriptExecutionContext* context) +bool WorkerFileSystemClient::allowFileSystem(ExecutionContext* context) { WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); WebCore::WorkerThread* workerThread = workerGlobalScope->thread(); diff --git a/Source/web/WorkerFileSystemClient.h b/Source/web/WorkerFileSystemClient.h index 3999df9b7..2ab462647 100644 --- a/Source/web/WorkerFileSystemClient.h +++ b/Source/web/WorkerFileSystemClient.h @@ -41,7 +41,7 @@ public: static PassOwnPtr<FileSystemClient> create(); virtual ~WorkerFileSystemClient(); - virtual bool allowFileSystem(WebCore::ScriptExecutionContext*) OVERRIDE; + virtual bool allowFileSystem(WebCore::ExecutionContext*) OVERRIDE; private: WorkerFileSystemClient(); diff --git a/Source/web/blink_common.target.darwin-arm.mk b/Source/web/blink_common.target.darwin-arm.mk deleted file mode 100644 index ff9acce60..000000000 --- a/Source/web/blink_common.target.darwin-arm.mk +++ /dev/null @@ -1,356 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := third_party_WebKit_Source_web_blink_common_gyp -LOCAL_MODULE_SUFFIX := .a -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ - $(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \ - $(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp - -GYP_GENERATED_OUTPUTS := - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/WebCString.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebString.cpp \ - third_party/WebKit/Source/web/WebCommon.cpp - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. - -LOCAL_LDFLAGS_Debug := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -Wl,-z,relro \ - -Wl,-z,now \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--icf=safe \ - -Wl,--fatal-warnings \ - -Wl,--gc-sections \ - -Wl,--warn-shared-textrel \ - -Wl,-O1 \ - -Wl,--as-needed - - -LOCAL_LDFLAGS_Release := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -Wl,-z,relro \ - -Wl,-z,now \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--icf=safe \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,--fatal-warnings \ - -Wl,--warn-shared-textrel - - -LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) - -LOCAL_STATIC_LIBRARIES := \ - skia_skia_library_gyp - -# Enable grouping to fix circular references -LOCAL_GROUP_STATIC_LIBRARIES := true - -LOCAL_SHARED_LIBRARIES := \ - libstlport \ - libdl - -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: third_party_WebKit_Source_web_blink_common_gyp - -# Alias gyp target name. -.PHONY: blink_common -blink_common: third_party_WebKit_Source_web_blink_common_gyp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Source/web/blink_common.target.darwin-mips.mk b/Source/web/blink_common.target.darwin-mips.mk deleted file mode 100644 index 711af5416..000000000 --- a/Source/web/blink_common.target.darwin-mips.mk +++ /dev/null @@ -1,352 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := third_party_WebKit_Source_web_blink_common_gyp -LOCAL_MODULE_SUFFIX := .a -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ - $(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \ - $(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp - -GYP_GENERATED_OUTPUTS := - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/WebCString.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebString.cpp \ - third_party/WebKit/Source/web/WebCommon.cpp - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. - -LOCAL_LDFLAGS_Debug := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -EL \ - -Wl,--no-keep-memory \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--fatal-warnings \ - -Wl,--gc-sections \ - -Wl,--warn-shared-textrel \ - -Wl,-O1 \ - -Wl,--as-needed - - -LOCAL_LDFLAGS_Release := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -EL \ - -Wl,--no-keep-memory \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,--fatal-warnings \ - -Wl,--warn-shared-textrel - - -LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) - -LOCAL_STATIC_LIBRARIES := \ - skia_skia_library_gyp - -# Enable grouping to fix circular references -LOCAL_GROUP_STATIC_LIBRARIES := true - -LOCAL_SHARED_LIBRARIES := \ - libstlport \ - libdl - -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: third_party_WebKit_Source_web_blink_common_gyp - -# Alias gyp target name. -.PHONY: blink_common -blink_common: third_party_WebKit_Source_web_blink_common_gyp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Source/web/blink_common.target.darwin-x86.mk b/Source/web/blink_common.target.darwin-x86.mk deleted file mode 100644 index 2e11dcce1..000000000 --- a/Source/web/blink_common.target.darwin-x86.mk +++ /dev/null @@ -1,356 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := third_party_WebKit_Source_web_blink_common_gyp -LOCAL_MODULE_SUFFIX := .a -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ - $(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \ - $(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp - -GYP_GENERATED_OUTPUTS := - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/WebCString.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebString.cpp \ - third_party/WebKit/Source/web/WebCommon.cpp - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -fno-stack-protector \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -fno-stack-protector \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer \ - -fno-unwind-tables \ - -fno-asynchronous-unwind-tables - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. - -LOCAL_LDFLAGS_Debug := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -m32 \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--fatal-warnings \ - -Wl,--gc-sections \ - -Wl,--warn-shared-textrel \ - -Wl,-O1 \ - -Wl,--as-needed - - -LOCAL_LDFLAGS_Release := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -m32 \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,--fatal-warnings \ - -Wl,--warn-shared-textrel - - -LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) - -LOCAL_STATIC_LIBRARIES := \ - skia_skia_library_gyp - -# Enable grouping to fix circular references -LOCAL_GROUP_STATIC_LIBRARIES := true - -LOCAL_SHARED_LIBRARIES := \ - libstlport \ - libdl - -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: third_party_WebKit_Source_web_blink_common_gyp - -# Alias gyp target name. -.PHONY: blink_common -blink_common: third_party_WebKit_Source_web_blink_common_gyp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Source/web/blink_common.target.linux-arm.mk b/Source/web/blink_common.target.linux-arm.mk deleted file mode 100644 index ff9acce60..000000000 --- a/Source/web/blink_common.target.linux-arm.mk +++ /dev/null @@ -1,356 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := third_party_WebKit_Source_web_blink_common_gyp -LOCAL_MODULE_SUFFIX := .a -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ - $(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \ - $(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp - -GYP_GENERATED_OUTPUTS := - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/WebCString.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebString.cpp \ - third_party/WebKit/Source/web/WebCommon.cpp - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. - -LOCAL_LDFLAGS_Debug := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -Wl,-z,relro \ - -Wl,-z,now \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--icf=safe \ - -Wl,--fatal-warnings \ - -Wl,--gc-sections \ - -Wl,--warn-shared-textrel \ - -Wl,-O1 \ - -Wl,--as-needed - - -LOCAL_LDFLAGS_Release := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -Wl,-z,relro \ - -Wl,-z,now \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--icf=safe \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,--fatal-warnings \ - -Wl,--warn-shared-textrel - - -LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) - -LOCAL_STATIC_LIBRARIES := \ - skia_skia_library_gyp - -# Enable grouping to fix circular references -LOCAL_GROUP_STATIC_LIBRARIES := true - -LOCAL_SHARED_LIBRARIES := \ - libstlport \ - libdl - -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: third_party_WebKit_Source_web_blink_common_gyp - -# Alias gyp target name. -.PHONY: blink_common -blink_common: third_party_WebKit_Source_web_blink_common_gyp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Source/web/blink_common.target.linux-mips.mk b/Source/web/blink_common.target.linux-mips.mk deleted file mode 100644 index 711af5416..000000000 --- a/Source/web/blink_common.target.linux-mips.mk +++ /dev/null @@ -1,352 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := third_party_WebKit_Source_web_blink_common_gyp -LOCAL_MODULE_SUFFIX := .a -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ - $(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \ - $(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp - -GYP_GENERATED_OUTPUTS := - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/WebCString.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebString.cpp \ - third_party/WebKit/Source/web/WebCommon.cpp - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. - -LOCAL_LDFLAGS_Debug := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -EL \ - -Wl,--no-keep-memory \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--fatal-warnings \ - -Wl,--gc-sections \ - -Wl,--warn-shared-textrel \ - -Wl,-O1 \ - -Wl,--as-needed - - -LOCAL_LDFLAGS_Release := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -EL \ - -Wl,--no-keep-memory \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,--fatal-warnings \ - -Wl,--warn-shared-textrel - - -LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) - -LOCAL_STATIC_LIBRARIES := \ - skia_skia_library_gyp - -# Enable grouping to fix circular references -LOCAL_GROUP_STATIC_LIBRARIES := true - -LOCAL_SHARED_LIBRARIES := \ - libstlport \ - libdl - -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: third_party_WebKit_Source_web_blink_common_gyp - -# Alias gyp target name. -.PHONY: blink_common -blink_common: third_party_WebKit_Source_web_blink_common_gyp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Source/web/blink_common.target.linux-x86.mk b/Source/web/blink_common.target.linux-x86.mk deleted file mode 100644 index 2e11dcce1..000000000 --- a/Source/web/blink_common.target.linux-x86.mk +++ /dev/null @@ -1,356 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := third_party_WebKit_Source_web_blink_common_gyp -LOCAL_MODULE_SUFFIX := .a -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ - $(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \ - $(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp - -GYP_GENERATED_OUTPUTS := - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/WebCString.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebString.cpp \ - third_party/WebKit/Source/web/WebCommon.cpp - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -fno-stack-protector \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - --param=ssp-buffer-size=4 \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -Wno-format \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Wno-address \ - -Wno-format-security \ - -Wno-return-type \ - -Wno-sequence-point \ - -fno-stack-protector \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer \ - -fno-unwind-tables \ - -fno-asynchronous-unwind-tables - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-DCLD_VERSION=1' \ - '-DINSIDE_WEBKIT' \ - '-DBLINK_COMMON_IMPLEMENTATION=1' \ - '-DENABLE_CSS3_TEXT=0' \ - '-DENABLE_CSS_EXCLUSIONS=1' \ - '-DENABLE_CSS_REGIONS=1' \ - '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ - '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ - '-DENABLE_SVG_FONTS=1' \ - '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ - '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ - '-DENABLE_CALENDAR_PICKER=0' \ - '-DENABLE_FAST_MOBILE_SCROLLING=1' \ - '-DENABLE_INPUT_SPEECH=0' \ - '-DENABLE_LEGACY_NOTIFICATIONS=0' \ - '-DENABLE_MEDIA_CAPTURE=1' \ - '-DENABLE_ORIENTATION_EVENTS=1' \ - '-DENABLE_NAVIGATOR_CONTENT_UTILS=0' \ - '-DENABLE_OPENTYPE_VERTICAL=1' \ - '-DU_USING_ICU_NAMESPACE=0' \ - '-DSK_ENABLE_INST_COUNT=0' \ - '-DSK_SUPPORT_GPU=1' \ - '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \ - '-DSK_ENABLE_LEGACY_API_ALIASING=1' \ - '-DSK_BUILD_FOR_ANDROID' \ - '-DSK_USE_POSIX_THREADS' \ - '-DSK_DEFERRED_CANVAS_USES_FACTORIES=1' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ - $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ - $(LOCAL_PATH)/third_party/WebKit/Source \ - $(LOCAL_PATH)/third_party/WebKit \ - $(PWD)/external/icu4c/common \ - $(PWD)/external/icu4c/i18n \ - $(LOCAL_PATH)/third_party/skia/src/core \ - $(LOCAL_PATH)/skia/config \ - $(LOCAL_PATH)/third_party/skia/include/config \ - $(LOCAL_PATH)/third_party/skia/include/core \ - $(LOCAL_PATH)/third_party/skia/include/effects \ - $(LOCAL_PATH)/third_party/skia/include/pdf \ - $(LOCAL_PATH)/third_party/skia/include/gpu \ - $(LOCAL_PATH)/third_party/skia/include/lazy \ - $(LOCAL_PATH)/third_party/skia/include/pathops \ - $(LOCAL_PATH)/third_party/skia/include/pipe \ - $(LOCAL_PATH)/third_party/skia/include/ports \ - $(LOCAL_PATH)/third_party/skia/include/utils \ - $(LOCAL_PATH)/skia/ext \ - $(LOCAL_PATH)/v8/include \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -Wno-c++0x-compat \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wno-deprecated \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo \ - -Wno-non-virtual-dtor - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. - -LOCAL_LDFLAGS_Debug := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -m32 \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,--fatal-warnings \ - -Wl,--gc-sections \ - -Wl,--warn-shared-textrel \ - -Wl,-O1 \ - -Wl,--as-needed - - -LOCAL_LDFLAGS_Release := \ - -Wl,-z,now \ - -Wl,-z,relro \ - -Wl,-z,noexecstack \ - -fPIC \ - -m32 \ - -fuse-ld=gold \ - -nostdlib \ - -Wl,--no-undefined \ - -Wl,--exclude-libs=ALL \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,--fatal-warnings \ - -Wl,--warn-shared-textrel - - -LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) - -LOCAL_STATIC_LIBRARIES := \ - skia_skia_library_gyp - -# Enable grouping to fix circular references -LOCAL_GROUP_STATIC_LIBRARIES := true - -LOCAL_SHARED_LIBRARIES := \ - libstlport \ - libdl - -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: third_party_WebKit_Source_web_blink_common_gyp - -# Alias gyp target name. -.PHONY: blink_common -blink_common: third_party_WebKit_Source_web_blink_common_gyp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Source/web/linux/WebFontRendering.cpp b/Source/web/linux/WebFontRendering.cpp index 03b92dcf8..c20d4b4f5 100644 --- a/Source/web/linux/WebFontRendering.cpp +++ b/Source/web/linux/WebFontRendering.cpp @@ -33,7 +33,7 @@ #include "core/platform/graphics/FontPlatformData.h" -#if OS(LINUX) && !OS(ANDROID) +#if OS(LINUX) #include "WebFontInfo.h" #endif @@ -75,7 +75,7 @@ void WebFontRendering::setSubpixelRendering(bool useSubpixelRendering) void WebFontRendering::setSubpixelPositioning(bool useSubpixelPositioning) { FontPlatformData::setSubpixelPositioning(useSubpixelPositioning); -#if OS(LINUX) && !OS(ANDROID) +#if OS(LINUX) WebFontInfo::setSubpixelPositioning(useSubpixelPositioning); #endif } diff --git a/Source/web/mac/WebInputEventFactory.mm b/Source/web/mac/WebInputEventFactory.mm index da074e058..5fa1a0062 100644 --- a/Source/web/mac/WebInputEventFactory.mm +++ b/Source/web/mac/WebInputEventFactory.mm @@ -32,7 +32,7 @@ #import <Cocoa/Cocoa.h> #include "WebInputEvent.h" -#import "core/platform/cocoa/KeyEventCocoa.h" +#include "core/platform/WindowsKeyboardCodes.h" #include "wtf/ASCIICType.h" #if __MAC_OS_X_VERSION_MAX_ALLOWED == 1060 @@ -66,18 +66,208 @@ enum { namespace WebKit { -// WebKeyboardEvent ----------------------------------------------------------- +static int windowsKeyCodeForKeyCode(uint16_t keyCode) +{ + static const int windowsKeyCode[] = { + /* 0 */ VK_A, + /* 1 */ VK_S, + /* 2 */ VK_D, + /* 3 */ VK_F, + /* 4 */ VK_H, + /* 5 */ VK_G, + /* 6 */ VK_Z, + /* 7 */ VK_X, + /* 8 */ VK_C, + /* 9 */ VK_V, + /* 0x0A */ VK_OEM_3, // "Section" - key to the left from 1 (ISO Keyboard Only) + /* 0x0B */ VK_B, + /* 0x0C */ VK_Q, + /* 0x0D */ VK_W, + /* 0x0E */ VK_E, + /* 0x0F */ VK_R, + /* 0x10 */ VK_Y, + /* 0x11 */ VK_T, + /* 0x12 */ VK_1, + /* 0x13 */ VK_2, + /* 0x14 */ VK_3, + /* 0x15 */ VK_4, + /* 0x16 */ VK_6, + /* 0x17 */ VK_5, + /* 0x18 */ VK_OEM_PLUS, // =+ + /* 0x19 */ VK_9, + /* 0x1A */ VK_7, + /* 0x1B */ VK_OEM_MINUS, // -_ + /* 0x1C */ VK_8, + /* 0x1D */ VK_0, + /* 0x1E */ VK_OEM_6, // ]} + /* 0x1F */ VK_O, + /* 0x20 */ VK_U, + /* 0x21 */ VK_OEM_4, // {[ + /* 0x22 */ VK_I, + /* 0x23 */ VK_P, + /* 0x24 */ VK_RETURN, // Return + /* 0x25 */ VK_L, + /* 0x26 */ VK_J, + /* 0x27 */ VK_OEM_7, // '" + /* 0x28 */ VK_K, + /* 0x29 */ VK_OEM_1, // ;: + /* 0x2A */ VK_OEM_5, // \| + /* 0x2B */ VK_OEM_COMMA, // ,< + /* 0x2C */ VK_OEM_2, // /? + /* 0x2D */ VK_N, + /* 0x2E */ VK_M, + /* 0x2F */ VK_OEM_PERIOD, // .> + /* 0x30 */ VK_TAB, + /* 0x31 */ VK_SPACE, + /* 0x32 */ VK_OEM_3, // `~ + /* 0x33 */ VK_BACK, // Backspace + /* 0x34 */ 0, // n/a + /* 0x35 */ VK_ESCAPE, + /* 0x36 */ VK_APPS, // Right Command + /* 0x37 */ VK_LWIN, // Left Command + /* 0x38 */ VK_LSHIFT, // Left Shift + /* 0x39 */ VK_CAPITAL, // Caps Lock + /* 0x3A */ VK_LMENU, // Left Option + /* 0x3B */ VK_LCONTROL, // Left Ctrl + /* 0x3C */ VK_RSHIFT, // Right Shift + /* 0x3D */ VK_RMENU, // Right Option + /* 0x3E */ VK_RCONTROL, // Right Ctrl + /* 0x3F */ 0, // fn + /* 0x40 */ VK_F17, + /* 0x41 */ VK_DECIMAL, // Num Pad . + /* 0x42 */ 0, // n/a + /* 0x43 */ VK_MULTIPLY, // Num Pad * + /* 0x44 */ 0, // n/a + /* 0x45 */ VK_ADD, // Num Pad + + /* 0x46 */ 0, // n/a + /* 0x47 */ VK_CLEAR, // Num Pad Clear + /* 0x48 */ VK_VOLUME_UP, + /* 0x49 */ VK_VOLUME_DOWN, + /* 0x4A */ VK_VOLUME_MUTE, + /* 0x4B */ VK_DIVIDE, // Num Pad / + /* 0x4C */ VK_RETURN, // Num Pad Enter + /* 0x4D */ 0, // n/a + /* 0x4E */ VK_SUBTRACT, // Num Pad - + /* 0x4F */ VK_F18, + /* 0x50 */ VK_F19, + /* 0x51 */ VK_OEM_PLUS, // Num Pad =. There is no such key on common PC keyboards, mapping to normal "+=". + /* 0x52 */ VK_NUMPAD0, + /* 0x53 */ VK_NUMPAD1, + /* 0x54 */ VK_NUMPAD2, + /* 0x55 */ VK_NUMPAD3, + /* 0x56 */ VK_NUMPAD4, + /* 0x57 */ VK_NUMPAD5, + /* 0x58 */ VK_NUMPAD6, + /* 0x59 */ VK_NUMPAD7, + /* 0x5A */ VK_F20, + /* 0x5B */ VK_NUMPAD8, + /* 0x5C */ VK_NUMPAD9, + /* 0x5D */ 0, // Yen (JIS Keyboard Only) + /* 0x5E */ 0, // Underscore (JIS Keyboard Only) + /* 0x5F */ 0, // KeypadComma (JIS Keyboard Only) + /* 0x60 */ VK_F5, + /* 0x61 */ VK_F6, + /* 0x62 */ VK_F7, + /* 0x63 */ VK_F3, + /* 0x64 */ VK_F8, + /* 0x65 */ VK_F9, + /* 0x66 */ 0, // Eisu (JIS Keyboard Only) + /* 0x67 */ VK_F11, + /* 0x68 */ 0, // Kana (JIS Keyboard Only) + /* 0x69 */ VK_F13, + /* 0x6A */ VK_F16, + /* 0x6B */ VK_F14, + /* 0x6C */ 0, // n/a + /* 0x6D */ VK_F10, + /* 0x6E */ 0, // n/a (Windows95 key?) + /* 0x6F */ VK_F12, + /* 0x70 */ 0, // n/a + /* 0x71 */ VK_F15, + /* 0x72 */ VK_INSERT, // Help + /* 0x73 */ VK_HOME, // Home + /* 0x74 */ VK_PRIOR, // Page Up + /* 0x75 */ VK_DELETE, // Forward Delete + /* 0x76 */ VK_F4, + /* 0x77 */ VK_END, // End + /* 0x78 */ VK_F2, + /* 0x79 */ VK_NEXT, // Page Down + /* 0x7A */ VK_F1, + /* 0x7B */ VK_LEFT, // Left Arrow + /* 0x7C */ VK_RIGHT, // Right Arrow + /* 0x7D */ VK_DOWN, // Down Arrow + /* 0x7E */ VK_UP, // Up Arrow + /* 0x7F */ 0 // n/a + }; + + if (keyCode >= 0x80) + return 0; + + return windowsKeyCode[keyCode]; +} -// ---------------------------------------------------------------------------- -// Begin Apple code, copied from KeyEventMac.mm -// -// We can share some of this code if we factored it out of KeyEventMac, but -// the main problem is that it relies on the NSString ctor on String for -// conversions, and since we're building without PLATFORM(MAC), we don't have -// that. As a result we have to use NSString here exclusively and thus tweak -// the code so it's not re-usable as-is. One possiblity would be to make the -// upstream code only use NSString, but I'm not certain how far that change -// would propagate. +static int windowsKeyCodeForCharCode(unichar charCode) +{ + switch (charCode) { + + case 'a': case 'A': return VK_A; + case 'b': case 'B': return VK_B; + case 'c': case 'C': return VK_C; + case 'd': case 'D': return VK_D; + case 'e': case 'E': return VK_E; + case 'f': case 'F': return VK_F; + case 'g': case 'G': return VK_G; + case 'h': case 'H': return VK_H; + case 'i': case 'I': return VK_I; + case 'j': case 'J': return VK_J; + case 'k': case 'K': return VK_K; + case 'l': case 'L': return VK_L; + case 'm': case 'M': return VK_M; + case 'n': case 'N': return VK_N; + case 'o': case 'O': return VK_O; + case 'p': case 'P': return VK_P; + case 'q': case 'Q': return VK_Q; + case 'r': case 'R': return VK_R; + case 's': case 'S': return VK_S; + case 't': case 'T': return VK_T; + case 'u': case 'U': return VK_U; + case 'v': case 'V': return VK_V; + case 'w': case 'W': return VK_W; + case 'x': case 'X': return VK_X; + case 'y': case 'Y': return VK_Y; + case 'z': case 'Z': return VK_Z; + + // AppKit generates Unicode PUA character codes for some function keys; using these when key code is not known. + case NSPauseFunctionKey: return VK_PAUSE; + case NSSelectFunctionKey: return VK_SELECT; + case NSPrintFunctionKey: return VK_PRINT; + case NSExecuteFunctionKey: return VK_EXECUTE; + case NSPrintScreenFunctionKey: return VK_SNAPSHOT; + case NSInsertFunctionKey: return VK_INSERT; + + case NSF21FunctionKey: return VK_F21; + case NSF22FunctionKey: return VK_F22; + case NSF23FunctionKey: return VK_F23; + case NSF24FunctionKey: return VK_F24; + case NSScrollLockFunctionKey: return VK_SCROLL; + + // This is for U.S. keyboard mapping, and doesn't necessarily make sense for different keyboard layouts. + // For example, '"' on Windows Russian layout is VK_2, not VK_OEM_7. + case ';': case ':': return VK_OEM_1; + case '=': case '+': return VK_OEM_PLUS; + case ',': case '<': return VK_OEM_COMMA; + case '-': case '_': return VK_OEM_MINUS; + case '.': case '>': return VK_OEM_PERIOD; + case '/': case '?': return VK_OEM_2; + case '`': case '~': return VK_OEM_3; + case '[': case '{': return VK_OEM_4; + case '\\': case '|': return VK_OEM_5; + case ']': case '}': return VK_OEM_6; + case '\'': case '"': return VK_OEM_7; + + } + + return 0; +} static inline bool isKeyUpEvent(NSEvent* event) { @@ -160,20 +350,20 @@ static int windowsKeyCodeForKeyEvent(NSEvent* event) if (!isKeypadEvent(event) && ([event type] == NSKeyDown || [event type] == NSKeyUp)) { // Cmd switches Roman letters for Dvorak-QWERTY layout, so try modified characters first. NSString* s = [event characters]; - code = [s length] > 0 ? WebCore::windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; + code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; if (code) return code; // Ctrl+A on an AZERTY keyboard would get VK_Q keyCode if we relied on -[NSEvent keyCode] below. s = [event charactersIgnoringModifiers]; - code = [s length] > 0 ? WebCore::windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; + code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; if (code) return code; } // Map Mac virtual key code directly to Windows one for any keys not handled above. // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboard ('A') and on Russian keyboard (CYRILLIC LETTER EF). - return WebCore::windowsKeyCodeForKeyCode([event keyCode]); + return windowsKeyCodeForKeyCode([event keyCode]); } static WebInputEvent::Type gestureEventTypeForEvent(NSEvent *event) diff --git a/Source/web/mac/WebSubstringUtil.mm b/Source/web/mac/WebSubstringUtil.mm index 9f6a1b39e..1f59597d3 100644 --- a/Source/web/mac/WebSubstringUtil.mm +++ b/Source/web/mac/WebSubstringUtil.mm @@ -1,11 +1,11 @@ /* * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -15,7 +15,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -43,8 +43,8 @@ #include "core/editing/FrameSelection.h" #include "core/editing/TextIterator.h" #include "core/html/HTMLElement.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/platform/graphics/Font.h" #include "core/platform/graphics/mac/ColorMac.h" #include "core/rendering/RenderObject.h" diff --git a/Source/web/painting/ContinuousPainter.cpp b/Source/web/painting/ContinuousPainter.cpp index e17a4248a..5a690cc4b 100644 --- a/Source/web/painting/ContinuousPainter.cpp +++ b/Source/web/painting/ContinuousPainter.cpp @@ -30,8 +30,8 @@ #include "ContinuousPainter.h" #include "PageOverlayList.h" -#include "core/platform/chromium/TraceEvent.h" #include "core/platform/graphics/GraphicsLayer.h" +#include "platform/TraceEvent.h" using namespace WebCore; diff --git a/Source/web/painting/PaintAggregator.h b/Source/web/painting/PaintAggregator.h index 96afe10d8..cc12b935c 100644 --- a/Source/web/painting/PaintAggregator.h +++ b/Source/web/painting/PaintAggregator.h @@ -31,8 +31,8 @@ #ifndef PaintAggregator_h #define PaintAggregator_h -#include "core/platform/graphics/IntPoint.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/geometry/IntPoint.h" +#include "platform/geometry/IntRect.h" #include "wtf/Vector.h" namespace WebKit { diff --git a/Source/web/picker_resources.target.darwin-arm.mk b/Source/web/picker_resources.target.darwin-arm.mk new file mode 100644 index 000000000..381392a52 --- /dev/null +++ b/Source/web/picker_resources.target.darwin-arm.mk @@ -0,0 +1,78 @@ +# This file is generated by gyp; do not edit. + +include $(CLEAR_VARS) + +LOCAL_MODULE_CLASS := GYP +LOCAL_MODULE := third_party_WebKit_Source_web_picker_resources_gyp +LOCAL_MODULE_STEM := picker_resources +LOCAL_MODULE_SUFFIX := .stamp +LOCAL_MODULE_TAGS := optional +gyp_intermediate_dir := $(call local-intermediates-dir) +gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) + +# Make sure our deps are built first. +GYP_TARGET_DEPENDENCIES := + +### Rules for action "PickerCommon": +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_PickerCommon ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/PickerCommon.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp" resources/pickerCommon.css resources/pickerCommon.js + +$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp: $(gyp_shared_intermediate_dir)/blink/PickerCommon.h ; + +### Rules for action "CalendarPicker": +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.js $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerButton.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_CalendarPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--condition=ENABLE(CALENDAR_PICKER)" "--out-h=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp" resources/calendarPicker.css resources/calendarPicker.js resources/pickerButton.css resources/suggestionPicker.css resources/suggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp: $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h ; + +### Rules for action "ColorSuggestionPicker": +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_ColorSuggestionPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp" resources/colorSuggestionPicker.css resources/colorSuggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp: $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h ; + + +GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.h \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp + +# Make sure our deps and generated files are built first. +LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) + +### Rules for final target. +# Add target alias to "gyp_all_modules" target. +.PHONY: gyp_all_modules +gyp_all_modules: third_party_WebKit_Source_web_picker_resources_gyp + +# Alias gyp target name. +.PHONY: picker_resources +picker_resources: third_party_WebKit_Source_web_picker_resources_gyp + +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) + $(hide) echo "Gyp timestamp: $@" + $(hide) mkdir -p $(dir $@) + $(hide) touch $@ diff --git a/Source/web/picker_resources.target.darwin-mips.mk b/Source/web/picker_resources.target.darwin-mips.mk new file mode 100644 index 000000000..381392a52 --- /dev/null +++ b/Source/web/picker_resources.target.darwin-mips.mk @@ -0,0 +1,78 @@ +# This file is generated by gyp; do not edit. + +include $(CLEAR_VARS) + +LOCAL_MODULE_CLASS := GYP +LOCAL_MODULE := third_party_WebKit_Source_web_picker_resources_gyp +LOCAL_MODULE_STEM := picker_resources +LOCAL_MODULE_SUFFIX := .stamp +LOCAL_MODULE_TAGS := optional +gyp_intermediate_dir := $(call local-intermediates-dir) +gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) + +# Make sure our deps are built first. +GYP_TARGET_DEPENDENCIES := + +### Rules for action "PickerCommon": +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_PickerCommon ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/PickerCommon.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp" resources/pickerCommon.css resources/pickerCommon.js + +$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp: $(gyp_shared_intermediate_dir)/blink/PickerCommon.h ; + +### Rules for action "CalendarPicker": +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.js $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerButton.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_CalendarPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--condition=ENABLE(CALENDAR_PICKER)" "--out-h=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp" resources/calendarPicker.css resources/calendarPicker.js resources/pickerButton.css resources/suggestionPicker.css resources/suggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp: $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h ; + +### Rules for action "ColorSuggestionPicker": +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_ColorSuggestionPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp" resources/colorSuggestionPicker.css resources/colorSuggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp: $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h ; + + +GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.h \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp + +# Make sure our deps and generated files are built first. +LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) + +### Rules for final target. +# Add target alias to "gyp_all_modules" target. +.PHONY: gyp_all_modules +gyp_all_modules: third_party_WebKit_Source_web_picker_resources_gyp + +# Alias gyp target name. +.PHONY: picker_resources +picker_resources: third_party_WebKit_Source_web_picker_resources_gyp + +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) + $(hide) echo "Gyp timestamp: $@" + $(hide) mkdir -p $(dir $@) + $(hide) touch $@ diff --git a/Source/web/picker_resources.target.darwin-x86.mk b/Source/web/picker_resources.target.darwin-x86.mk new file mode 100644 index 000000000..381392a52 --- /dev/null +++ b/Source/web/picker_resources.target.darwin-x86.mk @@ -0,0 +1,78 @@ +# This file is generated by gyp; do not edit. + +include $(CLEAR_VARS) + +LOCAL_MODULE_CLASS := GYP +LOCAL_MODULE := third_party_WebKit_Source_web_picker_resources_gyp +LOCAL_MODULE_STEM := picker_resources +LOCAL_MODULE_SUFFIX := .stamp +LOCAL_MODULE_TAGS := optional +gyp_intermediate_dir := $(call local-intermediates-dir) +gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) + +# Make sure our deps are built first. +GYP_TARGET_DEPENDENCIES := + +### Rules for action "PickerCommon": +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_PickerCommon ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/PickerCommon.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp" resources/pickerCommon.css resources/pickerCommon.js + +$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp: $(gyp_shared_intermediate_dir)/blink/PickerCommon.h ; + +### Rules for action "CalendarPicker": +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.js $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerButton.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_CalendarPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--condition=ENABLE(CALENDAR_PICKER)" "--out-h=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp" resources/calendarPicker.css resources/calendarPicker.js resources/pickerButton.css resources/suggestionPicker.css resources/suggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp: $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h ; + +### Rules for action "ColorSuggestionPicker": +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_ColorSuggestionPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp" resources/colorSuggestionPicker.css resources/colorSuggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp: $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h ; + + +GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.h \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp + +# Make sure our deps and generated files are built first. +LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) + +### Rules for final target. +# Add target alias to "gyp_all_modules" target. +.PHONY: gyp_all_modules +gyp_all_modules: third_party_WebKit_Source_web_picker_resources_gyp + +# Alias gyp target name. +.PHONY: picker_resources +picker_resources: third_party_WebKit_Source_web_picker_resources_gyp + +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) + $(hide) echo "Gyp timestamp: $@" + $(hide) mkdir -p $(dir $@) + $(hide) touch $@ diff --git a/Source/web/picker_resources.target.linux-arm.mk b/Source/web/picker_resources.target.linux-arm.mk new file mode 100644 index 000000000..381392a52 --- /dev/null +++ b/Source/web/picker_resources.target.linux-arm.mk @@ -0,0 +1,78 @@ +# This file is generated by gyp; do not edit. + +include $(CLEAR_VARS) + +LOCAL_MODULE_CLASS := GYP +LOCAL_MODULE := third_party_WebKit_Source_web_picker_resources_gyp +LOCAL_MODULE_STEM := picker_resources +LOCAL_MODULE_SUFFIX := .stamp +LOCAL_MODULE_TAGS := optional +gyp_intermediate_dir := $(call local-intermediates-dir) +gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) + +# Make sure our deps are built first. +GYP_TARGET_DEPENDENCIES := + +### Rules for action "PickerCommon": +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_PickerCommon ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/PickerCommon.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp" resources/pickerCommon.css resources/pickerCommon.js + +$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp: $(gyp_shared_intermediate_dir)/blink/PickerCommon.h ; + +### Rules for action "CalendarPicker": +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.js $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerButton.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_CalendarPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--condition=ENABLE(CALENDAR_PICKER)" "--out-h=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp" resources/calendarPicker.css resources/calendarPicker.js resources/pickerButton.css resources/suggestionPicker.css resources/suggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp: $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h ; + +### Rules for action "ColorSuggestionPicker": +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_ColorSuggestionPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp" resources/colorSuggestionPicker.css resources/colorSuggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp: $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h ; + + +GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.h \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp + +# Make sure our deps and generated files are built first. +LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) + +### Rules for final target. +# Add target alias to "gyp_all_modules" target. +.PHONY: gyp_all_modules +gyp_all_modules: third_party_WebKit_Source_web_picker_resources_gyp + +# Alias gyp target name. +.PHONY: picker_resources +picker_resources: third_party_WebKit_Source_web_picker_resources_gyp + +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) + $(hide) echo "Gyp timestamp: $@" + $(hide) mkdir -p $(dir $@) + $(hide) touch $@ diff --git a/Source/web/picker_resources.target.linux-mips.mk b/Source/web/picker_resources.target.linux-mips.mk new file mode 100644 index 000000000..381392a52 --- /dev/null +++ b/Source/web/picker_resources.target.linux-mips.mk @@ -0,0 +1,78 @@ +# This file is generated by gyp; do not edit. + +include $(CLEAR_VARS) + +LOCAL_MODULE_CLASS := GYP +LOCAL_MODULE := third_party_WebKit_Source_web_picker_resources_gyp +LOCAL_MODULE_STEM := picker_resources +LOCAL_MODULE_SUFFIX := .stamp +LOCAL_MODULE_TAGS := optional +gyp_intermediate_dir := $(call local-intermediates-dir) +gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) + +# Make sure our deps are built first. +GYP_TARGET_DEPENDENCIES := + +### Rules for action "PickerCommon": +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_PickerCommon ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/PickerCommon.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp" resources/pickerCommon.css resources/pickerCommon.js + +$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp: $(gyp_shared_intermediate_dir)/blink/PickerCommon.h ; + +### Rules for action "CalendarPicker": +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.js $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerButton.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_CalendarPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--condition=ENABLE(CALENDAR_PICKER)" "--out-h=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp" resources/calendarPicker.css resources/calendarPicker.js resources/pickerButton.css resources/suggestionPicker.css resources/suggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp: $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h ; + +### Rules for action "ColorSuggestionPicker": +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_ColorSuggestionPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp" resources/colorSuggestionPicker.css resources/colorSuggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp: $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h ; + + +GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.h \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp + +# Make sure our deps and generated files are built first. +LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) + +### Rules for final target. +# Add target alias to "gyp_all_modules" target. +.PHONY: gyp_all_modules +gyp_all_modules: third_party_WebKit_Source_web_picker_resources_gyp + +# Alias gyp target name. +.PHONY: picker_resources +picker_resources: third_party_WebKit_Source_web_picker_resources_gyp + +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) + $(hide) echo "Gyp timestamp: $@" + $(hide) mkdir -p $(dir $@) + $(hide) touch $@ diff --git a/Source/web/picker_resources.target.linux-x86.mk b/Source/web/picker_resources.target.linux-x86.mk new file mode 100644 index 000000000..381392a52 --- /dev/null +++ b/Source/web/picker_resources.target.linux-x86.mk @@ -0,0 +1,78 @@ +# This file is generated by gyp; do not edit. + +include $(CLEAR_VARS) + +LOCAL_MODULE_CLASS := GYP +LOCAL_MODULE := third_party_WebKit_Source_web_picker_resources_gyp +LOCAL_MODULE_STEM := picker_resources +LOCAL_MODULE_SUFFIX := .stamp +LOCAL_MODULE_TAGS := optional +gyp_intermediate_dir := $(call local-intermediates-dir) +gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) + +# Make sure our deps are built first. +GYP_TARGET_DEPENDENCIES := + +### Rules for action "PickerCommon": +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/PickerCommon.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerCommon.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_PickerCommon ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/PickerCommon.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp" resources/pickerCommon.css resources/pickerCommon.js + +$(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp: $(gyp_shared_intermediate_dir)/blink/PickerCommon.h ; + +### Rules for action "CalendarPicker": +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/calendarPicker.js $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/pickerButton.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/suggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_CalendarPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--condition=ENABLE(CALENDAR_PICKER)" "--out-h=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp" resources/calendarPicker.css resources/calendarPicker.js resources/pickerButton.css resources/suggestionPicker.css resources/suggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp: $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h ; + +### Rules for action "ColorSuggestionPicker": +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h: $(LOCAL_PATH)/third_party/WebKit/Source/web/scripts/make-file-arrays.py $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.css $(LOCAL_PATH)/third_party/WebKit/Source/web/resources/colorSuggestionPicker.js $(GYP_TARGET_DEPENDENCIES) + @echo "Gyp action: third_party_WebKit_Source_web_web_gyp_picker_resources_target_ColorSuggestionPicker ($@)" + $(hide)cd $(gyp_local_path)/third_party/WebKit/Source/web; mkdir -p $(gyp_shared_intermediate_dir)/blink; python scripts/make-file-arrays.py "--out-h=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h" "--out-cpp=$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp" resources/colorSuggestionPicker.css resources/colorSuggestionPicker.js + +$(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp: $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h ; + + +GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.h \ + $(gyp_shared_intermediate_dir)/blink/PickerCommon.cpp \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.h \ + $(gyp_shared_intermediate_dir)/blink/CalendarPicker.cpp \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.h \ + $(gyp_shared_intermediate_dir)/blink/ColorSuggestionPicker.cpp + +# Make sure our deps and generated files are built first. +LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) + +### Rules for final target. +# Add target alias to "gyp_all_modules" target. +.PHONY: gyp_all_modules +gyp_all_modules: third_party_WebKit_Source_web_picker_resources_gyp + +# Alias gyp target name. +.PHONY: picker_resources +picker_resources: third_party_WebKit_Source_web_picker_resources_gyp + +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) + $(hide) echo "Gyp timestamp: $@" + $(hide) mkdir -p $(dir $@) + $(hide) touch $@ diff --git a/Source/web/resources/calendarPicker.css b/Source/web/resources/calendarPicker.css new file mode 100644 index 000000000..afe4dbf19 --- /dev/null +++ b/Source/web/resources/calendarPicker.css @@ -0,0 +1,319 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +body { + -webkit-user-select: none; + background-color: white; + font: -webkit-control; + font-size: 12px; +} + +.rtl { + direction: rtl; +} + +.scroll-view { + overflow: hidden; + width: 0; + height: 0; +} + +.list-cell { + position: absolute; + left: 0; + top: 0; + width: 0; + height: 0; +} + +.list-cell.hidden { + display: none; +} + +.week-number-cell, +.day-cell { + position: static; + text-align: center; + box-sizing: border-box; + display: inline-block; + cursor: default; + transition: color 1s; + padding: 1px; +} + +.week-number-cell { + box-sizing: border-box; + color: black; + padding-right: 0; + box-shadow: 1px 0 0 #bfbfbf; + margin-right: 1px; +} + +.day-cell { + color: #bfbfbf; +} + +.day-cell.highlighted.today, +.day-cell.today { + border: 1px solid #bfbfbf; + padding: 0; +} + +.week-number-cell.highlighted, +.day-cell.highlighted { + background-color: #e5ecf8; +} + +.week-number-cell.highlighted.disabled, +.day-cell.highlighted.disabled { + border: 1px solid #e5ecf8; + padding: 0; +} + +.week-number-cell.selected, +.day-cell.selected { + background-color: #bccdec; +} + +.week-number-cell.disabled, +.day-cell.disabled { + background-color: #f5f5f5; +} + +.day-cell.current-month { + color: #000000; +} + +.calendar-table-view { + border: 1px solid #bfbfbf; + display: inline-block; + outline: none; +} + +.week-number-label, +.week-day-label { + text-align: center; + display: inline-block; + line-height: 23px; + padding-top: 1px; + box-sizing: padding-box; +} + +.week-number-label { + box-sizing: border-box; + border-right: 1px solid #bfbfbf; +} + +.calendar-table-header-view { + background-color: #f5f5f5; + border-bottom: 1px solid #bfbfbf; + height: 24px; +} + +.calendar-picker { + border: 1px solid #bfbfbf; + border-radius: 2px; + position: absolute; + padding: 10px; + background-color: white; + overflow: hidden; + cursor: default; +} + +.calendar-header-view { + margin-bottom: 10px; + display: flex; + flex-flow: row; +} + +.calendar-title { + -webkit-align-self: center; + flex: 1; + text-align: left; +} + +.rtl .calendar-title { + text-align: right; +} + +.month-popup-button, +.month-popup-button:hover, +.month-popup-button:disabled { + background-color: transparent !important; + background-image: none !important; + box-shadow: none !important; + color: black; +} + +.month-popup-button:disabled { + opacity: 0.7; +} + +.month-popup-button { + font-size: 12px; + padding: 4px; + display: inline-block; + cursor: default; + border: 1px solid transparent !important; + height: 24px !important; +} + +.month-popup-button .disclosure-triangle { + margin: 0 6px; +} + +.month-popup-button .disclosure-triangle svg { + padding-bottom: 2px; +} + +.today-button::after { + content: ""; + display: block; + border-radius: 3px; + width: 6px; + height: 6px; + background-color: #6e6e6e; + margin: 0 auto; +} + +.calendar-navigation-button { + -webkit-align-self: center; + width: 24px; + height: 24px; + min-width: 0 !important; + padding-left: 0 !important; + padding-right: 0 !important; + -webkit-margin-start: 4px !important; +} + +.year-list-view { + border: 1px solid #bfbfbf; + background-color: white; + position: absolute; +} + +.year-list-cell { + box-sizing: border-box; + border-bottom: 1px solid #bfbfbf; + background-color: white; + overflow: hidden; +} + +.year-list-cell .label { + height: 24px; + line-height: 24px; + -webkit-padding-start: 8px; + background-color: #f5f5f5; + border-bottom: 1px solid #bfbfbf; +} + +.year-list-cell .month-chooser { + padding: 0; +} + +.month-buttons-row { + display: flex; +} + +.month-button { + flex: 1; + height: 32px; + padding: 0 !important; + margin: 0 !important; + background-image: none !important; + background-color: #ffffff; + border-width: 0 !important; + box-shadow: none !important; +} + +.month-button.highlighted { + background-color: #e5ecf8; +} + +.scrubby-scroll-bar { + width: 14px; + height: 60px; + background-color: white; + border-left: 1px solid #bfbfbf; + position: absolute; + top: 0; +} + +.scrubby-scroll-thumb { + width: 10px; + margin: 2px; + height: 30px; + background-color: #d8d8d8; + position: absolute; + left: 0; + top: 0; +} + +.month-popup-view { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.year-list-view .scrubby-scroll-bar { + right: 0; +} + +.rtl .year-list-view .scrubby-scroll-bar { + left: 0; + right: auto; + border-left-width: 0; + border-right: 1px solid #bfbfbf; +} + +.year-month-button { + width: 24px; + height: 24px; + min-width: 0; + padding: 0; +} + +.month-popup-button:focus, +.year-list-view:focus, +.calendar-table-view:focus { + transition: border-color 200ms; + /* We use border color because it follows the border radius (unlike outline). + * This is particularly noticeable on mac. */ + border-color: rgb(77, 144, 254) !important; + outline: none; +} + +.preparing button:focus, +.preparing .year-list-view:focus, +.preparing .calendar-table-view:focus { + transition: none; +} diff --git a/Source/web/resources/calendarPicker.js b/Source/web/resources/calendarPicker.js new file mode 100644 index 000000000..a01c5ba76 --- /dev/null +++ b/Source/web/resources/calendarPicker.js @@ -0,0 +1,4009 @@ +"use strict"; +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +/** + * @enum {number} + */ +var WeekDay = { + Sunday: 0, + Monday: 1, + Tuesday: 2, + Wednesday: 3, + Thursday: 4, + Friday: 5, + Saturday: 6 +}; + +/** + * @type {Object} + */ +var global = { + picker: null, + params: { + locale: "en_US", + weekStartDay: WeekDay.Sunday, + dayLabels: ["S", "M", "T", "W", "T", "F", "S"], + shortMonthLabels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], + isLocaleRTL: false, + mode: "date", + weekLabel: "Week", + anchorRectInScreen: new Rectangle(0, 0, 0, 0), + currentValue: null + } +}; + +// ---------------------------------------------------------------- +// Utility functions + +/** + * @return {!bool} + */ +function hasInaccuratePointingDevice() { + return matchMedia("(pointer: coarse)").matches; +} + +/** + * @return {!string} lowercase locale name. e.g. "en-us" + */ +function getLocale() { + return (global.params.locale || "en-us").toLowerCase(); +} + +/** + * @return {!string} lowercase language code. e.g. "en" + */ +function getLanguage() { + var locale = getLocale(); + var result = locale.match(/^([a-z]+)/); + if (!result) + return "en"; + return result[1]; +} + +/** + * @param {!number} number + * @return {!string} + */ +function localizeNumber(number) { + return window.pagePopupController.localizeNumberString(number); +} + +/** + * @const + * @type {number} + */ +var ImperialEraLimit = 2087; + +/** + * @param {!number} year + * @param {!number} month + * @return {!string} + */ +function formatJapaneseImperialEra(year, month) { + // We don't show an imperial era if it is greater than 99 becase of space + // limitation. + if (year > ImperialEraLimit) + return ""; + if (year > 1989) + return "(平成" + localizeNumber(year - 1988) + "年)"; + if (year == 1989) + return "(平成元年)"; + if (year >= 1927) + return "(昭和" + localizeNumber(year - 1925) + "年)"; + if (year > 1912) + return "(大正" + localizeNumber(year - 1911) + "年)"; + if (year == 1912 && month >= 7) + return "(大正元年)"; + if (year > 1868) + return "(明治" + localizeNumber(year - 1867) + "年)"; + if (year == 1868) + return "(明治元年)"; + return ""; +} + +function createUTCDate(year, month, date) { + var newDate = new Date(0); + newDate.setUTCFullYear(year); + newDate.setUTCMonth(month); + newDate.setUTCDate(date); + return newDate; +} + +/** + * @param {string} dateString + * @return {?Day|Week|Month} + */ +function parseDateString(dateString) { + var month = Month.parse(dateString); + if (month) + return month; + var week = Week.parse(dateString); + if (week) + return week; + return Day.parse(dateString); +} + +/** + * @const + * @type {number} + */ +var DaysPerWeek = 7; + +/** + * @const + * @type {number} + */ +var MonthsPerYear = 12; + +/** + * @const + * @type {number} + */ +var MillisecondsPerDay = 24 * 60 * 60 * 1000; + +/** + * @const + * @type {number} + */ +var MillisecondsPerWeek = DaysPerWeek * MillisecondsPerDay; + +/** + * @constructor + */ +function DateType() { +} + +/** + * @constructor + * @extends DateType + * @param {!number} year + * @param {!number} month + * @param {!number} date + */ +function Day(year, month, date) { + var dateObject = createUTCDate(year, month, date); + if (isNaN(dateObject.valueOf())) + throw "Invalid date"; + /** + * @type {number} + * @const + */ + this.year = dateObject.getUTCFullYear(); + /** + * @type {number} + * @const + */ + this.month = dateObject.getUTCMonth(); + /** + * @type {number} + * @const + */ + this.date = dateObject.getUTCDate(); +}; + +Day.prototype = Object.create(DateType.prototype); + +Day.ISOStringRegExp = /^(\d+)-(\d+)-(\d+)/; + +/** + * @param {!string} str + * @return {?Day} + */ +Day.parse = function(str) { + var match = Day.ISOStringRegExp.exec(str); + if (!match) + return null; + var year = parseInt(match[1], 10); + var month = parseInt(match[2], 10) - 1; + var date = parseInt(match[3], 10); + return new Day(year, month, date); +}; + +/** + * @param {!number} value + * @return {!Day} + */ +Day.createFromValue = function(millisecondsSinceEpoch) { + return Day.createFromDate(new Date(millisecondsSinceEpoch)) +}; + +/** + * @param {!Date} date + * @return {!Day} + */ +Day.createFromDate = function(date) { + if (isNaN(date.valueOf())) + throw "Invalid date"; + return new Day(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()); +}; + +/** + * @param {!Day} day + * @return {!Day} + */ +Day.createFromDay = function(day) { + return day; +}; + +/** + * @return {!Day} + */ +Day.createFromToday = function() { + var now = new Date(); + return new Day(now.getFullYear(), now.getMonth(), now.getDate()); +}; + +/** + * @param {!DateType} other + * @return {!boolean} + */ +Day.prototype.equals = function(other) { + return other instanceof Day && this.year === other.year && this.month === other.month && this.date === other.date; +}; + +/** + * @param {!number=} offset + * @return {!Day} + */ +Day.prototype.previous = function(offset) { + if (typeof offset === "undefined") + offset = 1; + return new Day(this.year, this.month, this.date - offset); +}; + +/** + * @param {!number=} offset + * @return {!Day} + */ +Day.prototype.next = function(offset) { + if (typeof offset === "undefined") + offset = 1; + return new Day(this.year, this.month, this.date + offset); +}; + +/** + * @return {!Date} + */ +Day.prototype.startDate = function() { + return createUTCDate(this.year, this.month, this.date); +}; + +/** + * @return {!Date} + */ +Day.prototype.endDate = function() { + return createUTCDate(this.year, this.month, this.date + 1); +}; + +/** + * @return {!Day} + */ +Day.prototype.firstDay = function() { + return this; +}; + +/** + * @return {!Day} + */ +Day.prototype.middleDay = function() { + return this; +}; + +/** + * @return {!Day} + */ +Day.prototype.lastDay = function() { + return this; +}; + +/** + * @return {!number} + */ +Day.prototype.valueOf = function() { + return createUTCDate(this.year, this.month, this.date).getTime(); +}; + +/** + * @return {!WeekDay} + */ +Day.prototype.weekDay = function() { + return createUTCDate(this.year, this.month, this.date).getUTCDay(); +}; + +/** + * @return {!string} + */ +Day.prototype.toString = function() { + var yearString = String(this.year); + if (yearString.length < 4) + yearString = ("000" + yearString).substr(-4, 4); + return yearString + "-" + ("0" + (this.month + 1)).substr(-2, 2) + "-" + ("0" + this.date).substr(-2, 2); +}; + +// See WebCore/platform/DateComponents.h. +Day.Minimum = Day.createFromValue(-62135596800000.0); +Day.Maximum = Day.createFromValue(8640000000000000.0); + +// See WebCore/html/DayInputType.cpp. +Day.DefaultStep = 86400000; +Day.DefaultStepBase = 0; + +/** + * @constructor + * @extends DateType + * @param {!number} year + * @param {!number} week + */ +function Week(year, week) { + /** + * @type {number} + * @const + */ + this.year = year; + /** + * @type {number} + * @const + */ + this.week = week; + // Number of years per year is either 52 or 53. + if (this.week < 1 || (this.week > 52 && this.week > Week.numberOfWeeksInYear(this.year))) { + var normalizedWeek = Week.createFromDay(this.firstDay()); + this.year = normalizedWeek.year; + this.week = normalizedWeek.week; + } +} + +Week.ISOStringRegExp = /^(\d+)-[wW](\d+)$/; + +// See WebCore/platform/DateComponents.h. +Week.Minimum = new Week(1, 1); +Week.Maximum = new Week(275760, 37); + +// See WebCore/html/WeekInputType.cpp. +Week.DefaultStep = 604800000; +Week.DefaultStepBase = -259200000; + +Week.EpochWeekDay = createUTCDate(1970, 0, 0).getUTCDay(); + +/** + * @param {!string} str + * @return {?Week} + */ +Week.parse = function(str) { + var match = Week.ISOStringRegExp.exec(str); + if (!match) + return null; + var year = parseInt(match[1], 10); + var week = parseInt(match[2], 10); + return new Week(year, week); +}; + +/** + * @param {!number} millisecondsSinceEpoch + * @return {!Week} + */ +Week.createFromValue = function(millisecondsSinceEpoch) { + return Week.createFromDate(new Date(millisecondsSinceEpoch)) +}; + +/** + * @param {!Date} date + * @return {!Week} + */ +Week.createFromDate = function(date) { + if (isNaN(date.valueOf())) + throw "Invalid date"; + var year = date.getUTCFullYear(); + if (year <= Week.Maximum.year && Week.weekOneStartDateForYear(year + 1).getTime() <= date.getTime()) + year++; + else if (year > 1 && Week.weekOneStartDateForYear(year).getTime() > date.getTime()) + year--; + var week = 1 + Week._numberOfWeeksSinceDate(Week.weekOneStartDateForYear(year), date); + return new Week(year, week); +}; + +/** + * @param {!Day} day + * @return {!Week} + */ +Week.createFromDay = function(day) { + var year = day.year; + if (year <= Week.Maximum.year && Week.weekOneStartDayForYear(year + 1) <= day) + year++; + else if (year > 1 && Week.weekOneStartDayForYear(year) > day) + year--; + var week = Math.floor(1 + (day.valueOf() - Week.weekOneStartDayForYear(year).valueOf()) / MillisecondsPerWeek); + return new Week(year, week); +}; + +/** + * @return {!Week} + */ +Week.createFromToday = function() { + var now = new Date(); + return Week.createFromDate(createUTCDate(now.getFullYear(), now.getMonth(), now.getDate())); +}; + +/** + * @param {!number} year + * @return {!Date} + */ +Week.weekOneStartDateForYear = function(year) { + if (year < 1) + return createUTCDate(1, 0, 1); + // The week containing January 4th is week one. + var yearStartDay = createUTCDate(year, 0, 4).getUTCDay(); + return createUTCDate(year, 0, 4 - (yearStartDay + 6) % DaysPerWeek); +}; + +/** + * @param {!number} year + * @return {!Day} + */ +Week.weekOneStartDayForYear = function(year) { + if (year < 1) + return Day.Minimum; + // The week containing January 4th is week one. + var yearStartDay = createUTCDate(year, 0, 4).getUTCDay(); + return new Day(year, 0, 4 - (yearStartDay + 6) % DaysPerWeek); +}; + +/** + * @param {!number} year + * @return {!number} + */ +Week.numberOfWeeksInYear = function(year) { + if (year < 1 || year > Week.Maximum.year) + return 0; + else if (year === Week.Maximum.year) + return Week.Maximum.week; + return Week._numberOfWeeksSinceDate(Week.weekOneStartDateForYear(year), Week.weekOneStartDateForYear(year + 1)); +}; + +/** + * @param {!Date} baseDate + * @param {!Date} date + * @return {!number} + */ +Week._numberOfWeeksSinceDate = function(baseDate, date) { + return Math.floor((date.getTime() - baseDate.getTime()) / MillisecondsPerWeek); +}; + +/** + * @param {!DateType} other + * @return {!boolean} + */ +Week.prototype.equals = function(other) { + return other instanceof Week && this.year === other.year && this.week === other.week; +}; + +/** + * @param {!number=} offset + * @return {!Week} + */ +Week.prototype.previous = function(offset) { + if (typeof offset === "undefined") + offset = 1; + return new Week(this.year, this.week - offset); +}; + +/** + * @param {!number=} offset + * @return {!Week} + */ +Week.prototype.next = function(offset) { + if (typeof offset === "undefined") + offset = 1; + return new Week(this.year, this.week + offset); +}; + +/** + * @return {!Date} + */ +Week.prototype.startDate = function() { + var weekStartDate = Week.weekOneStartDateForYear(this.year); + weekStartDate.setUTCDate(weekStartDate.getUTCDate() + (this.week - 1) * 7); + return weekStartDate; +}; + +/** + * @return {!Date} + */ +Week.prototype.endDate = function() { + if (this.equals(Week.Maximum)) + return Day.Maximum.startDate(); + return this.next().startDate(); +}; + +/** + * @return {!Day} + */ +Week.prototype.firstDay = function() { + var weekOneStartDay = Week.weekOneStartDayForYear(this.year); + return weekOneStartDay.next((this.week - 1) * DaysPerWeek); +}; + +/** + * @return {!Day} + */ +Week.prototype.middleDay = function() { + return this.firstDay().next(3); +}; + +/** + * @return {!Day} + */ +Week.prototype.lastDay = function() { + if (this.equals(Week.Maximum)) + return Day.Maximum; + return this.next().firstDay().previous(); +}; + +/** + * @return {!number} + */ +Week.prototype.valueOf = function() { + return this.firstDay().valueOf() - createUTCDate(1970, 0, 1).getTime(); +}; + +/** + * @return {!string} + */ +Week.prototype.toString = function() { + var yearString = String(this.year); + if (yearString.length < 4) + yearString = ("000" + yearString).substr(-4, 4); + return yearString + "-W" + ("0" + this.week).substr(-2, 2); +}; + +/** + * @constructor + * @extends DateType + * @param {!number} year + * @param {!number} month + */ +function Month(year, month) { + /** + * @type {number} + * @const + */ + this.year = year + Math.floor(month / MonthsPerYear); + /** + * @type {number} + * @const + */ + this.month = month % MonthsPerYear < 0 ? month % MonthsPerYear + MonthsPerYear : month % MonthsPerYear; +}; + +Month.ISOStringRegExp = /^(\d+)-(\d+)$/; + +// See WebCore/platform/DateComponents.h. +Month.Minimum = new Month(1, 0); +Month.Maximum = new Month(275760, 8); + +// See WebCore/html/MonthInputType.cpp. +Month.DefaultStep = 1; +Month.DefaultStepBase = 0; + +/** + * @param {!string} str + * @return {?Month} + */ +Month.parse = function(str) { + var match = Month.ISOStringRegExp.exec(str); + if (!match) + return null; + var year = parseInt(match[1], 10); + var month = parseInt(match[2], 10) - 1; + return new Month(year, month); +}; + +/** + * @param {!number} value + * @return {!Month} + */ +Month.createFromValue = function(monthsSinceEpoch) { + return new Month(1970, monthsSinceEpoch) +}; + +/** + * @param {!Date} date + * @return {!Month} + */ +Month.createFromDate = function(date) { + if (isNaN(date.valueOf())) + throw "Invalid date"; + return new Month(date.getUTCFullYear(), date.getUTCMonth()); +}; + +/** + * @param {!Day} day + * @return {!Month} + */ +Month.createFromDay = function(day) { + return new Month(day.year, day.month); +}; + +/** + * @return {!Month} + */ +Month.createFromToday = function() { + var now = new Date(); + return new Month(now.getFullYear(), now.getMonth()); +}; + +/** + * @return {!boolean} + */ +Month.prototype.containsDay = function(day) { + return this.year === day.year && this.month === day.month; +}; + +/** + * @param {!Month} other + * @return {!boolean} + */ +Month.prototype.equals = function(other) { + return other instanceof Month && this.year === other.year && this.month === other.month; +}; + +/** + * @param {!number=} offset + * @return {!Month} + */ +Month.prototype.previous = function(offset) { + if (typeof offset === "undefined") + offset = 1; + return new Month(this.year, this.month - offset); +}; + +/** + * @param {!number=} offset + * @return {!Month} + */ +Month.prototype.next = function(offset) { + if (typeof offset === "undefined") + offset = 1; + return new Month(this.year, this.month + offset); +}; + +/** + * @return {!Date} + */ +Month.prototype.startDate = function() { + return createUTCDate(this.year, this.month, 1); +}; + +/** + * @return {!Date} + */ +Month.prototype.endDate = function() { + if (this.equals(Month.Maximum)) + return Day.Maximum.startDate(); + return this.next().startDate(); +}; + +/** + * @return {!Day} + */ +Month.prototype.firstDay = function() { + return new Day(this.year, this.month, 1); +}; + +/** + * @return {!Day} + */ +Month.prototype.middleDay = function() { + return new Day(this.year, this.month, this.month === 2 ? 14 : 15); +}; + +/** + * @return {!Day} + */ +Month.prototype.lastDay = function() { + if (this.equals(Month.Maximum)) + return Day.Maximum; + return this.next().firstDay().previous(); +}; + +/** + * @return {!number} + */ +Month.prototype.valueOf = function() { + return (this.year - 1970) * MonthsPerYear + this.month; +}; + +/** + * @return {!string} + */ +Month.prototype.toString = function() { + var yearString = String(this.year); + if (yearString.length < 4) + yearString = ("000" + yearString).substr(-4, 4); + return yearString + "-" + ("0" + (this.month + 1)).substr(-2, 2); +}; + +/** + * @return {!string} + */ +Month.prototype.toLocaleString = function() { + if (global.params.locale === "ja") + return "" + this.year + "年" + formatJapaneseImperialEra(this.year, this.month) + " " + (this.month + 1) + "月"; + return window.pagePopupController.formatMonth(this.year, this.month); +}; + +/** + * @return {!string} + */ +Month.prototype.toShortLocaleString = function() { + return window.pagePopupController.formatShortMonth(this.year, this.month); +}; + +// ---------------------------------------------------------------- +// Initialization + +/** + * @param {Event} event + */ +function handleMessage(event) { + if (global.argumentsReceived) + return; + global.argumentsReceived = true; + initialize(JSON.parse(event.data)); +} + +/** + * @param {!Object} params + */ +function setGlobalParams(params) { + var name; + for (name in global.params) { + if (typeof params[name] === "undefined") + console.warn("Missing argument: " + name); + } + for (name in params) { + global.params[name] = params[name]; + } +}; + +/** + * @param {!Object} args + */ +function initialize(args) { + setGlobalParams(args); + if (global.params.suggestionValues && global.params.suggestionValues.length) + openSuggestionPicker(); + else + openCalendarPicker(); +} + +function closePicker() { + if (global.picker) + global.picker.cleanup(); + var main = $("main"); + main.innerHTML = ""; + main.className = ""; +}; + +function openSuggestionPicker() { + closePicker(); + global.picker = new SuggestionPicker($("main"), global.params); +}; + +function openCalendarPicker() { + closePicker(); + global.picker = new CalendarPicker(global.params.mode, global.params); + global.picker.attachTo($("main")); +}; + +/** + * @constructor + */ +function EventEmitter() { +}; + +/** + * @param {!string} type + * @param {!function({...*})} callback + */ +EventEmitter.prototype.on = function(type, callback) { + console.assert(callback instanceof Function); + if (!this._callbacks) + this._callbacks = {}; + if (!this._callbacks[type]) + this._callbacks[type] = []; + this._callbacks[type].push(callback); +}; + +EventEmitter.prototype.hasListener = function(type) { + if (!this._callbacks) + return false; + var callbacksForType = this._callbacks[type]; + if (!callbacksForType) + return false; + return callbacksForType.length > 0; +}; + +/** + * @param {!string} type + * @param {!function(Object)} callback + */ +EventEmitter.prototype.removeListener = function(type, callback) { + if (!this._callbacks) + return; + var callbacksForType = this._callbacks[type]; + if (!callbacksForType) + return; + callbacksForType.splice(callbacksForType.indexOf(callback), 1); + if (callbacksForType.length === 0) + delete this._callbacks[type]; +}; + +/** + * @param {!string} type + * @param {...*} var_args + */ +EventEmitter.prototype.dispatchEvent = function(type) { + if (!this._callbacks) + return; + var callbacksForType = this._callbacks[type]; + if (!callbacksForType) + return; + for (var i = 0; i < callbacksForType.length; ++i) { + callbacksForType[i].apply(this, Array.prototype.slice.call(arguments, 1)); + } +}; + +// Parameter t should be a number between 0 and 1. +var AnimationTimingFunction = { + Linear: function(t){ + return t; + }, + EaseInOut: function(t){ + t *= 2; + if (t < 1) + return Math.pow(t, 3) / 2; + t -= 2; + return Math.pow(t, 3) / 2 + 1; + } +}; + +/** + * @constructor + * @extends EventEmitter + */ +function AnimationManager() { + EventEmitter.call(this); + + this._isRunning = false; + this._runningAnimatorCount = 0; + this._runningAnimators = {}; + this._animationFrameCallbackBound = this._animationFrameCallback.bind(this); +} + +AnimationManager.prototype = Object.create(EventEmitter.prototype); + +AnimationManager.EventTypeAnimationFrameWillFinish = "animationFrameWillFinish"; + +AnimationManager.prototype._startAnimation = function() { + if (this._isRunning) + return; + this._isRunning = true; + window.webkitRequestAnimationFrame(this._animationFrameCallbackBound); +}; + +AnimationManager.prototype._stopAnimation = function() { + if (!this._isRunning) + return; + this._isRunning = false; +}; + +/** + * @param {!Animator} animator + */ +AnimationManager.prototype.add = function(animator) { + if (this._runningAnimators[animator.id]) + return; + this._runningAnimators[animator.id] = animator; + this._runningAnimatorCount++; + if (this._needsTimer()) + this._startAnimation(); +}; + +/** + * @param {!Animator} animator + */ +AnimationManager.prototype.remove = function(animator) { + if (!this._runningAnimators[animator.id]) + return; + delete this._runningAnimators[animator.id]; + this._runningAnimatorCount--; + if (!this._needsTimer()) + this._stopAnimation(); +}; + +AnimationManager.prototype._animationFrameCallback = function(now) { + if (this._runningAnimatorCount > 0) { + for (var id in this._runningAnimators) { + this._runningAnimators[id].onAnimationFrame(now); + } + } + this.dispatchEvent(AnimationManager.EventTypeAnimationFrameWillFinish); + if (this._isRunning) + window.webkitRequestAnimationFrame(this._animationFrameCallbackBound); +}; + +/** + * @return {!boolean} + */ +AnimationManager.prototype._needsTimer = function() { + return this._runningAnimatorCount > 0 || this.hasListener(AnimationManager.EventTypeAnimationFrameWillFinish); +}; + +/** + * @param {!string} type + * @param {!Function} callback + * @override + */ +AnimationManager.prototype.on = function(type, callback) { + EventEmitter.prototype.on.call(this, type, callback); + if (this._needsTimer()) + this._startAnimation(); +}; + +/** + * @param {!string} type + * @param {!Function} callback + * @override + */ +AnimationManager.prototype.removeListener = function(type, callback) { + EventEmitter.prototype.removeListener.call(this, type, callback); + if (!this._needsTimer()) + this._stopAnimation(); +}; + +AnimationManager.shared = new AnimationManager(); + +/** + * @constructor + * @extends EventEmitter + */ +function Animator() { + EventEmitter.call(this); + + /** + * @type {!number} + * @const + */ + this.id = Animator._lastId++; + /** + * @type {!number} + */ + this.duration = 100; + /** + * @type {?function} + */ + this.step = null; + /** + * @type {!boolean} + * @protected + */ + this._isRunning = false; + /** + * @type {!number} + */ + this.currentValue = 0; + /** + * @type {!number} + * @protected + */ + this._lastStepTime = 0; +} + +Animator.prototype = Object.create(EventEmitter.prototype); + +Animator._lastId = 0; + +Animator.EventTypeDidAnimationStop = "didAnimationStop"; + +/** + * @return {!boolean} + */ +Animator.prototype.isRunning = function() { + return this._isRunning; +}; + +Animator.prototype.start = function() { + this._lastStepTime = Date.now(); + this._isRunning = true; + AnimationManager.shared.add(this); +}; + +Animator.prototype.stop = function() { + if (!this._isRunning) + return; + this._isRunning = false; + AnimationManager.shared.remove(this); + this.dispatchEvent(Animator.EventTypeDidAnimationStop, this); +}; + +/** + * @param {!number} now + */ +Animator.prototype.onAnimationFrame = function(now) { + this._lastStepTime = now; + this.step(this); +}; + +/** + * @constructor + * @extends Animator + */ +function TransitionAnimator() { + Animator.call(this); + /** + * @type {!number} + * @protected + */ + this._from = 0; + /** + * @type {!number} + * @protected + */ + this._to = 0; + /** + * @type {!number} + * @protected + */ + this._delta = 0; + /** + * @type {!number} + */ + this.progress = 0.0; + /** + * @type {!function} + */ + this.timingFunction = AnimationTimingFunction.Linear; +} + +TransitionAnimator.prototype = Object.create(Animator.prototype); + +/** + * @param {!number} value + */ +TransitionAnimator.prototype.setFrom = function(value) { + this._from = value; + this._delta = this._to - this._from; +}; + +TransitionAnimator.prototype.start = function() { + console.assert(isFinite(this.duration)); + this.progress = 0.0; + this.currentValue = this._from; + Animator.prototype.start.call(this); +}; + +/** + * @param {!number} value + */ +TransitionAnimator.prototype.setTo = function(value) { + this._to = value; + this._delta = this._to - this._from; +}; + +/** + * @param {!number} now + */ +TransitionAnimator.prototype.onAnimationFrame = function(now) { + this.progress += (now - this._lastStepTime) / this.duration; + this.progress = Math.min(1.0, this.progress); + this._lastStepTime = now; + this.currentValue = this.timingFunction(this.progress) * this._delta + this._from; + this.step(this); + if (this.progress === 1.0) { + this.stop(); + return; + } +}; + +/** + * @constructor + * @extends Animator + * @param {!number} initialVelocity + * @param {!number} initialValue + */ +function FlingGestureAnimator(initialVelocity, initialValue) { + Animator.call(this); + /** + * @type {!number} + */ + this.initialVelocity = initialVelocity; + /** + * @type {!number} + */ + this.initialValue = initialValue; + /** + * @type {!number} + * @protected + */ + this._elapsedTime = 0; + var startVelocity = Math.abs(this.initialVelocity); + if (startVelocity > this._velocityAtTime(0)) + startVelocity = this._velocityAtTime(0); + if (startVelocity < 0) + startVelocity = 0; + /** + * @type {!number} + * @protected + */ + this._timeOffset = this._timeAtVelocity(startVelocity); + /** + * @type {!number} + * @protected + */ + this._positionOffset = this._valueAtTime(this._timeOffset); + /** + * @type {!number} + */ + this.duration = this._timeAtVelocity(0); +} + +FlingGestureAnimator.prototype = Object.create(Animator.prototype); + +// Velocity is subject to exponential decay. These parameters are coefficients +// that determine the curve. +FlingGestureAnimator._P0 = -5707.62; +FlingGestureAnimator._P1 = 0.172; +FlingGestureAnimator._P2 = 0.0037; + +/** + * @param {!number} t + */ +FlingGestureAnimator.prototype._valueAtTime = function(t) { + return FlingGestureAnimator._P0 * Math.exp(-FlingGestureAnimator._P2 * t) - FlingGestureAnimator._P1 * t - FlingGestureAnimator._P0; +}; + +/** + * @param {!number} t + */ +FlingGestureAnimator.prototype._velocityAtTime = function(t) { + return -FlingGestureAnimator._P0 * FlingGestureAnimator._P2 * Math.exp(-FlingGestureAnimator._P2 * t) - FlingGestureAnimator._P1; +}; + +/** + * @param {!number} v + */ +FlingGestureAnimator.prototype._timeAtVelocity = function(v) { + return -Math.log((v + FlingGestureAnimator._P1) / (-FlingGestureAnimator._P0 * FlingGestureAnimator._P2)) / FlingGestureAnimator._P2; +}; + +FlingGestureAnimator.prototype.start = function() { + this._lastStepTime = Date.now(); + Animator.prototype.start.call(this); +}; + +/** + * @param {!number} now + */ +FlingGestureAnimator.prototype.onAnimationFrame = function(now) { + this._elapsedTime += now - this._lastStepTime; + this._lastStepTime = now; + if (this._elapsedTime + this._timeOffset >= this.duration) { + this.stop(); + return; + } + var position = this._valueAtTime(this._elapsedTime + this._timeOffset) - this._positionOffset; + if (this.initialVelocity < 0) + position = -position; + this.currentValue = position + this.initialValue; + this.step(this); +}; + +/** + * @constructor + * @extends EventEmitter + * @param {?Element} element + * View adds itself as a property on the element so we can access it from Event.target. + */ +function View(element) { + EventEmitter.call(this); + /** + * @type {Element} + * @const + */ + this.element = element || createElement("div"); + this.element.$view = this; + this.bindCallbackMethods(); +} + +View.prototype = Object.create(EventEmitter.prototype); + +/** + * @param {!Element} ancestorElement + * @return {?Object} + */ +View.prototype.offsetRelativeTo = function(ancestorElement) { + var x = 0; + var y = 0; + var element = this.element; + while (element) { + x += element.offsetLeft || 0; + y += element.offsetTop || 0; + element = element.offsetParent; + if (element === ancestorElement) + return {x: x, y: y}; + } + return null; +}; + +/** + * @param {!View|Node} parent + * @param {?View|Node=} before + */ +View.prototype.attachTo = function(parent, before) { + if (parent instanceof View) + return this.attachTo(parent.element, before); + if (typeof before === "undefined") + before = null; + if (before instanceof View) + before = before.element; + parent.insertBefore(this.element, before); +}; + +View.prototype.bindCallbackMethods = function() { + for (var methodName in this) { + if (!/^on[A-Z]/.test(methodName)) + continue; + if (this.hasOwnProperty(methodName)) + continue; + var method = this[methodName]; + if (!(method instanceof Function)) + continue; + this[methodName] = method.bind(this); + } +}; + +/** + * @constructor + * @extends View + */ +function ScrollView() { + View.call(this, createElement("div", ScrollView.ClassNameScrollView)); + /** + * @type {Element} + * @const + */ + this.contentElement = createElement("div", ScrollView.ClassNameScrollViewContent); + this.element.appendChild(this.contentElement); + /** + * @type {number} + */ + this.minimumContentOffset = -Infinity; + /** + * @type {number} + */ + this.maximumContentOffset = Infinity; + /** + * @type {number} + * @protected + */ + this._contentOffset = 0; + /** + * @type {number} + * @protected + */ + this._width = 0; + /** + * @type {number} + * @protected + */ + this._height = 0; + /** + * @type {Animator} + * @protected + */ + this._scrollAnimator = null; + /** + * @type {?Object} + */ + this.delegate = null; + /** + * @type {!number} + */ + this._lastTouchPosition = 0; + /** + * @type {!number} + */ + this._lastTouchVelocity = 0; + /** + * @type {!number} + */ + this._lastTouchTimeStamp = 0; + + this.element.addEventListener("mousewheel", this.onMouseWheel, false); + this.element.addEventListener("touchstart", this.onTouchStart, false); + + /** + * The content offset is partitioned so the it can go beyond the CSS limit + * of 33554433px. + * @type {number} + * @protected + */ + this._partitionNumber = 0; +} + +ScrollView.prototype = Object.create(View.prototype); + +ScrollView.PartitionHeight = 100000; +ScrollView.ClassNameScrollView = "scroll-view"; +ScrollView.ClassNameScrollViewContent = "scroll-view-content"; + +/** + * @param {!Event} event + */ +ScrollView.prototype.onTouchStart = function(event) { + var touch = event.touches[0]; + this._lastTouchPosition = touch.clientY; + this._lastTouchVelocity = 0; + this._lastTouchTimeStamp = event.timeStamp; + if (this._scrollAnimator) + this._scrollAnimator.stop(); + window.addEventListener("touchmove", this.onWindowTouchMove, false); + window.addEventListener("touchend", this.onWindowTouchEnd, false); +}; + +/** + * @param {!Event} event + */ +ScrollView.prototype.onWindowTouchMove = function(event) { + var touch = event.touches[0]; + var deltaTime = event.timeStamp - this._lastTouchTimeStamp; + var deltaY = this._lastTouchPosition - touch.clientY; + this.scrollBy(deltaY, false); + this._lastTouchVelocity = deltaY / deltaTime; + this._lastTouchPosition = touch.clientY; + this._lastTouchTimeStamp = event.timeStamp; + event.stopPropagation(); + event.preventDefault(); +}; + +/** + * @param {!Event} event + */ +ScrollView.prototype.onWindowTouchEnd = function(event) { + if (Math.abs(this._lastTouchVelocity) > 0.01) { + this._scrollAnimator = new FlingGestureAnimator(this._lastTouchVelocity, this._contentOffset); + this._scrollAnimator.step = this.onFlingGestureAnimatorStep; + this._scrollAnimator.start(); + } + window.removeEventListener("touchmove", this.onWindowTouchMove, false); + window.removeEventListener("touchend", this.onWindowTouchEnd, false); +}; + +/** + * @param {!Animator} animator + */ +ScrollView.prototype.onFlingGestureAnimatorStep = function(animator) { + this.scrollTo(animator.currentValue, false); +}; + +/** + * @return {!Animator} + */ +ScrollView.prototype.scrollAnimator = function() { + return this._scrollAnimator; +}; + +/** + * @param {!number} width + */ +ScrollView.prototype.setWidth = function(width) { + console.assert(isFinite(width)); + if (this._width === width) + return; + this._width = width; + this.element.style.width = this._width + "px"; +}; + +/** + * @return {!number} + */ +ScrollView.prototype.width = function() { + return this._width; +}; + +/** + * @param {!number} height + */ +ScrollView.prototype.setHeight = function(height) { + console.assert(isFinite(height)); + if (this._height === height) + return; + this._height = height; + this.element.style.height = height + "px"; + if (this.delegate) + this.delegate.scrollViewDidChangeHeight(this); +}; + +/** + * @return {!number} + */ +ScrollView.prototype.height = function() { + return this._height; +}; + +/** + * @param {!Animator} animator + */ +ScrollView.prototype.onScrollAnimatorStep = function(animator) { + this.setContentOffset(animator.currentValue); +}; + +/** + * @param {!number} offset + * @param {?boolean} animate + */ +ScrollView.prototype.scrollTo = function(offset, animate) { + console.assert(isFinite(offset)); + if (!animate) { + this.setContentOffset(offset); + return; + } + if (this._scrollAnimator) + this._scrollAnimator.stop(); + this._scrollAnimator = new TransitionAnimator(); + this._scrollAnimator.step = this.onScrollAnimatorStep; + this._scrollAnimator.setFrom(this._contentOffset); + this._scrollAnimator.setTo(offset); + this._scrollAnimator.duration = 300; + this._scrollAnimator.start(); +}; + +/** + * @param {!number} offset + * @param {?boolean} animate + */ +ScrollView.prototype.scrollBy = function(offset, animate) { + this.scrollTo(this._contentOffset + offset, animate); +}; + +/** + * @return {!number} + */ +ScrollView.prototype.contentOffset = function() { + return this._contentOffset; +}; + +/** + * @param {?Event} event + */ +ScrollView.prototype.onMouseWheel = function(event) { + this.setContentOffset(this._contentOffset - event.wheelDelta / 30); + event.stopPropagation(); + event.preventDefault(); +}; + + +/** + * @param {!number} value + */ +ScrollView.prototype.setContentOffset = function(value) { + console.assert(isFinite(value)); + value = Math.min(this.maximumContentOffset - this._height, Math.max(this.minimumContentOffset, Math.floor(value))); + if (this._contentOffset === value) + return; + var newPartitionNumber = Math.floor(value / ScrollView.PartitionHeight); + var partitionChanged = this._partitionNumber !== newPartitionNumber; + this._partitionNumber = newPartitionNumber; + this._contentOffset = value; + this.contentElement.style.webkitTransform = "translate(0, " + (-this.contentPositionForContentOffset(this._contentOffset)) + "px)"; + if (this.delegate) { + this.delegate.scrollViewDidChangeContentOffset(this); + if (partitionChanged) + this.delegate.scrollViewDidChangePartition(this); + } +}; + +/** + * @param {!number} offset + */ +ScrollView.prototype.contentPositionForContentOffset = function(offset) { + return offset - this._partitionNumber * ScrollView.PartitionHeight; +}; + +/** + * @constructor + * @extends View + */ +function ListCell() { + View.call(this, createElement("div", ListCell.ClassNameListCell)); + + /** + * @type {!number} + */ + this.row = NaN; + /** + * @type {!number} + */ + this._width = 0; + /** + * @type {!number} + */ + this._position = 0; +} + +ListCell.prototype = Object.create(View.prototype); + +ListCell.DefaultRecycleBinLimit = 64; +ListCell.ClassNameListCell = "list-cell"; +ListCell.ClassNameHidden = "hidden"; + +/** + * @return {!Array} An array to keep thrown away cells. + */ +ListCell.prototype._recycleBin = function() { + console.assert(false, "NOT REACHED: ListCell.prototype._recycleBin needs to be overridden."); + return []; +}; + +ListCell.prototype.throwAway = function() { + this.hide(); + var limit = typeof this.constructor.RecycleBinLimit === "undefined" ? ListCell.DefaultRecycleBinLimit : this.constructor.RecycleBinLimit; + var recycleBin = this._recycleBin(); + if (recycleBin.length < limit) + recycleBin.push(this); +}; + +ListCell.prototype.show = function() { + this.element.classList.remove(ListCell.ClassNameHidden); +}; + +ListCell.prototype.hide = function() { + this.element.classList.add(ListCell.ClassNameHidden); +}; + +/** + * @return {!number} Width in pixels. + */ +ListCell.prototype.width = function(){ + return this._width; +}; + +/** + * @param {!number} width Width in pixels. + */ +ListCell.prototype.setWidth = function(width){ + if (this._width === width) + return; + this._width = width; + this.element.style.width = this._width + "px"; +}; + +/** + * @return {!number} Position in pixels. + */ +ListCell.prototype.position = function(){ + return this._position; +}; + +/** + * @param {!number} y Position in pixels. + */ +ListCell.prototype.setPosition = function(y) { + if (this._position === y) + return; + this._position = y; + this.element.style.webkitTransform = "translate(0, " + this._position + "px)"; +}; + +/** + * @param {!boolean} selected + */ +ListCell.prototype.setSelected = function(selected) { + if (this._selected === selected) + return; + this._selected = selected; + if (this._selected) + this.element.classList.add("selected"); + else + this.element.classList.remove("selected"); +}; + +/** + * @constructor + * @extends View + */ +function ListView() { + View.call(this, createElement("div", ListView.ClassNameListView)); + this.element.tabIndex = 0; + + /** + * @type {!number} + * @private + */ + this._width = 0; + /** + * @type {!Object} + * @private + */ + this._cells = {}; + + /** + * @type {!number} + */ + this.selectedRow = ListView.NoSelection; + + /** + * @type {!ScrollView} + */ + this.scrollView = new ScrollView(); + this.scrollView.delegate = this; + this.scrollView.minimumContentOffset = 0; + this.scrollView.setWidth(0); + this.scrollView.setHeight(0); + this.scrollView.attachTo(this); + + this.element.addEventListener("click", this.onClick, false); + + /** + * @type {!boolean} + * @private + */ + this._needsUpdateCells = false; +} + +ListView.prototype = Object.create(View.prototype); + +ListView.NoSelection = -1; +ListView.ClassNameListView = "list-view"; + +ListView.prototype.onAnimationFrameWillFinish = function() { + if (this._needsUpdateCells) + this.updateCells(); +}; + +/** + * @param {!boolean} needsUpdateCells + */ +ListView.prototype.setNeedsUpdateCells = function(needsUpdateCells) { + if (this._needsUpdateCells === needsUpdateCells) + return; + this._needsUpdateCells = needsUpdateCells; + if (this._needsUpdateCells) + AnimationManager.shared.on(AnimationManager.EventTypeAnimationFrameWillFinish, this.onAnimationFrameWillFinish); + else + AnimationManager.shared.removeListener(AnimationManager.EventTypeAnimationFrameWillFinish, this.onAnimationFrameWillFinish); +}; + +/** + * @param {!number} row + * @return {?ListCell} + */ +ListView.prototype.cellAtRow = function(row) { + return this._cells[row]; +}; + +/** + * @param {!number} offset Scroll offset in pixels. + * @return {!number} + */ +ListView.prototype.rowAtScrollOffset = function(offset) { + console.assert(false, "NOT REACHED: ListView.prototype.rowAtScrollOffset needs to be overridden."); + return 0; +}; + +/** + * @param {!number} row + * @return {!number} Scroll offset in pixels. + */ +ListView.prototype.scrollOffsetForRow = function(row) { + console.assert(false, "NOT REACHED: ListView.prototype.scrollOffsetForRow needs to be overridden."); + return 0; +}; + +/** + * @param {!number} row + * @return {!ListCell} + */ +ListView.prototype.addCellIfNecessary = function(row) { + var cell = this._cells[row]; + if (cell) + return cell; + cell = this.prepareNewCell(row); + cell.attachTo(this.scrollView.contentElement); + cell.setWidth(this._width); + cell.setPosition(this.scrollView.contentPositionForContentOffset(this.scrollOffsetForRow(row))); + this._cells[row] = cell; + return cell; +}; + +/** + * @param {!number} row + * @return {!ListCell} + */ +ListView.prototype.prepareNewCell = function(row) { + console.assert(false, "NOT REACHED: ListView.prototype.prepareNewCell should be overridden."); + return new ListCell(); +}; + +/** + * @param {!ListCell} cell + */ +ListView.prototype.throwAwayCell = function(cell) { + delete this._cells[cell.row]; + cell.throwAway(); +}; + +/** + * @return {!number} + */ +ListView.prototype.firstVisibleRow = function() { + return this.rowAtScrollOffset(this.scrollView.contentOffset()); +}; + +/** + * @return {!number} + */ +ListView.prototype.lastVisibleRow = function() { + return this.rowAtScrollOffset(this.scrollView.contentOffset() + this.scrollView.height() - 1); +}; + +/** + * @param {!ScrollView} scrollView + */ +ListView.prototype.scrollViewDidChangeContentOffset = function(scrollView) { + this.setNeedsUpdateCells(true); +}; + +/** + * @param {!ScrollView} scrollView + */ +ListView.prototype.scrollViewDidChangeHeight = function(scrollView) { + this.setNeedsUpdateCells(true); +}; + +/** + * @param {!ScrollView} scrollView + */ +ListView.prototype.scrollViewDidChangePartition = function(scrollView) { + this.setNeedsUpdateCells(true); +}; + +ListView.prototype.updateCells = function() { + var firstVisibleRow = this.firstVisibleRow(); + var lastVisibleRow = this.lastVisibleRow(); + console.assert(firstVisibleRow <= lastVisibleRow); + for (var c in this._cells) { + var cell = this._cells[c]; + if (cell.row < firstVisibleRow || cell.row > lastVisibleRow) + this.throwAwayCell(cell); + } + for (var i = firstVisibleRow; i <= lastVisibleRow; ++i) { + var cell = this._cells[i]; + if (cell) + cell.setPosition(this.scrollView.contentPositionForContentOffset(this.scrollOffsetForRow(cell.row))); + else + this.addCellIfNecessary(i); + } + this.setNeedsUpdateCells(false); +}; + +/** + * @return {!number} Width in pixels. + */ +ListView.prototype.width = function() { + return this._width; +}; + +/** + * @param {!number} width Width in pixels. + */ +ListView.prototype.setWidth = function(width) { + if (this._width === width) + return; + this._width = width; + this.scrollView.setWidth(this._width); + for (var c in this._cells) { + this._cells[c].setWidth(this._width); + } + this.element.style.width = this._width + "px"; + this.setNeedsUpdateCells(true); +}; + +/** + * @return {!number} Height in pixels. + */ +ListView.prototype.height = function() { + return this.scrollView.height(); +}; + +/** + * @param {!number} height Height in pixels. + */ +ListView.prototype.setHeight = function(height) { + this.scrollView.setHeight(height); +}; + +/** + * @param {?Event} event + */ +ListView.prototype.onClick = function(event) { + var clickedCellElement = enclosingNodeOrSelfWithClass(event.target, ListCell.ClassNameListCell); + if (!clickedCellElement) + return; + var clickedCell = clickedCellElement.$view; + if (clickedCell.row !== this.selectedRow) + this.select(clickedCell.row); +}; + +/** + * @param {!number} row + */ +ListView.prototype.select = function(row) { + if (this.selectedRow === row) + return; + this.deselect(); + if (row === ListView.NoSelection) + return; + this.selectedRow = row; + var selectedCell = this._cells[this.selectedRow]; + if (selectedCell) + selectedCell.setSelected(true); +}; + +ListView.prototype.deselect = function() { + if (this.selectedRow === ListView.NoSelection) + return; + var selectedCell = this._cells[this.selectedRow]; + if (selectedCell) + selectedCell.setSelected(false); + this.selectedRow = ListView.NoSelection; +}; + +/** + * @param {!number} row + * @param {!boolean} animate + */ +ListView.prototype.scrollToRow = function(row, animate) { + this.scrollView.scrollTo(this.scrollOffsetForRow(row), animate); +}; + +/** + * @constructor + * @extends View + * @param {!ScrollView} scrollView + */ +function ScrubbyScrollBar(scrollView) { + View.call(this, createElement("div", ScrubbyScrollBar.ClassNameScrubbyScrollBar)); + + /** + * @type {!Element} + * @const + */ + this.thumb = createElement("div", ScrubbyScrollBar.ClassNameScrubbyScrollThumb); + this.element.appendChild(this.thumb); + + /** + * @type {!ScrollView} + * @const + */ + this.scrollView = scrollView; + + /** + * @type {!number} + * @protected + */ + this._height = 0; + /** + * @type {!number} + * @protected + */ + this._thumbHeight = 0; + /** + * @type {!number} + * @protected + */ + this._thumbPosition = 0; + + this.setHeight(0); + this.setThumbHeight(ScrubbyScrollBar.ThumbHeight); + + /** + * @type {?Animator} + * @protected + */ + this._thumbStyleTopAnimator = null; + + /** + * @type {?number} + * @protected + */ + this._timer = null; + + this.element.addEventListener("mousedown", this.onMouseDown, false); + this.element.addEventListener("touchstart", this.onTouchStart, false); +} + +ScrubbyScrollBar.prototype = Object.create(View.prototype); + +ScrubbyScrollBar.ScrollInterval = 16; +ScrubbyScrollBar.ThumbMargin = 2; +ScrubbyScrollBar.ThumbHeight = 30; +ScrubbyScrollBar.ClassNameScrubbyScrollBar = "scrubby-scroll-bar"; +ScrubbyScrollBar.ClassNameScrubbyScrollThumb = "scrubby-scroll-thumb"; + +/** + * @param {?Event} event + */ +ScrubbyScrollBar.prototype.onTouchStart = function(event) { + var touch = event.touches[0]; + this._setThumbPositionFromEventPosition(touch.clientY); + if (this._thumbStyleTopAnimator) + this._thumbStyleTopAnimator.stop(); + this._timer = setInterval(this.onScrollTimer, ScrubbyScrollBar.ScrollInterval); + window.addEventListener("touchmove", this.onWindowTouchMove, false); + window.addEventListener("touchend", this.onWindowTouchEnd, false); + event.stopPropagation(); + event.preventDefault(); +}; + +/** + * @param {?Event} event + */ +ScrubbyScrollBar.prototype.onWindowTouchMove = function(event) { + var touch = event.touches[0]; + this._setThumbPositionFromEventPosition(touch.clientY); + event.stopPropagation(); + event.preventDefault(); +}; + +/** + * @param {?Event} event + */ +ScrubbyScrollBar.prototype.onWindowTouchEnd = function(event) { + this._thumbStyleTopAnimator = new TransitionAnimator(); + this._thumbStyleTopAnimator.step = this.onThumbStyleTopAnimationStep; + this._thumbStyleTopAnimator.setFrom(this.thumb.offsetTop); + this._thumbStyleTopAnimator.setTo((this._height - this._thumbHeight) / 2); + this._thumbStyleTopAnimator.timingFunction = AnimationTimingFunction.EaseInOut; + this._thumbStyleTopAnimator.duration = 100; + this._thumbStyleTopAnimator.start(); + + window.removeEventListener("touchmove", this.onWindowTouchMove, false); + window.removeEventListener("touchend", this.onWindowTouchEnd, false); + clearInterval(this._timer); +}; + +/** + * @return {!number} Height of the view in pixels. + */ +ScrubbyScrollBar.prototype.height = function() { + return this._height; +}; + +/** + * @param {!number} height Height of the view in pixels. + */ +ScrubbyScrollBar.prototype.setHeight = function(height) { + if (this._height === height) + return; + this._height = height; + this.element.style.height = this._height + "px"; + this.thumb.style.top = ((this._height - this._thumbHeight) / 2) + "px"; + this._thumbPosition = 0; +}; + +/** + * @param {!number} height Height of the scroll bar thumb in pixels. + */ +ScrubbyScrollBar.prototype.setThumbHeight = function(height) { + if (this._thumbHeight === height) + return; + this._thumbHeight = height; + this.thumb.style.height = this._thumbHeight + "px"; + this.thumb.style.top = ((this._height - this._thumbHeight) / 2) + "px"; + this._thumbPosition = 0; +}; + +/** + * @param {number} position + */ +ScrubbyScrollBar.prototype._setThumbPositionFromEventPosition = function(position) { + var thumbMin = ScrubbyScrollBar.ThumbMargin; + var thumbMax = this._height - this._thumbHeight - ScrubbyScrollBar.ThumbMargin * 2; + var y = position - this.element.getBoundingClientRect().top - this.element.clientTop + this.element.scrollTop; + var thumbPosition = y - this._thumbHeight / 2; + thumbPosition = Math.max(thumbPosition, thumbMin); + thumbPosition = Math.min(thumbPosition, thumbMax); + this.thumb.style.top = thumbPosition + "px"; + this._thumbPosition = 1.0 - (thumbPosition - thumbMin) / (thumbMax - thumbMin) * 2; +}; + +/** + * @param {?Event} event + */ +ScrubbyScrollBar.prototype.onMouseDown = function(event) { + this._setThumbPositionFromEventPosition(event.clientY); + + window.addEventListener("mousemove", this.onWindowMouseMove, false); + window.addEventListener("mouseup", this.onWindowMouseUp, false); + if (this._thumbStyleTopAnimator) + this._thumbStyleTopAnimator.stop(); + this._timer = setInterval(this.onScrollTimer, ScrubbyScrollBar.ScrollInterval); + event.stopPropagation(); + event.preventDefault(); +}; + +/** + * @param {?Event} event + */ +ScrubbyScrollBar.prototype.onWindowMouseMove = function(event) { + this._setThumbPositionFromEventPosition(event.clientY); +}; + +/** + * @param {?Event} event + */ +ScrubbyScrollBar.prototype.onWindowMouseUp = function(event) { + this._thumbStyleTopAnimator = new TransitionAnimator(); + this._thumbStyleTopAnimator.step = this.onThumbStyleTopAnimationStep; + this._thumbStyleTopAnimator.setFrom(this.thumb.offsetTop); + this._thumbStyleTopAnimator.setTo((this._height - this._thumbHeight) / 2); + this._thumbStyleTopAnimator.timingFunction = AnimationTimingFunction.EaseInOut; + this._thumbStyleTopAnimator.duration = 100; + this._thumbStyleTopAnimator.start(); + + window.removeEventListener("mousemove", this.onWindowMouseMove, false); + window.removeEventListener("mouseup", this.onWindowMouseUp, false); + clearInterval(this._timer); +}; + +/** + * @param {!Animator} animator + */ +ScrubbyScrollBar.prototype.onThumbStyleTopAnimationStep = function(animator) { + this.thumb.style.top = animator.currentValue + "px"; +}; + +ScrubbyScrollBar.prototype.onScrollTimer = function() { + var scrollAmount = Math.pow(this._thumbPosition, 2) * 10; + if (this._thumbPosition > 0) + scrollAmount = -scrollAmount; + this.scrollView.scrollBy(scrollAmount, false); +}; + +/** + * @constructor + * @extends ListCell + * @param {!Array} shortMonthLabels + */ +function YearListCell(shortMonthLabels) { + ListCell.call(this); + this.element.classList.add(YearListCell.ClassNameYearListCell); + this.element.style.height = YearListCell.Height + "px"; + + /** + * @type {!Element} + * @const + */ + this.label = createElement("div", YearListCell.ClassNameLabel, "----"); + this.element.appendChild(this.label); + this.label.style.height = (YearListCell.Height - YearListCell.BorderBottomWidth) + "px"; + this.label.style.lineHeight = (YearListCell.Height - YearListCell.BorderBottomWidth) + "px"; + + /** + * @type {!Array} Array of the 12 month button elements. + * @const + */ + this.monthButtons = []; + var monthChooserElement = createElement("div", YearListCell.ClassNameMonthChooser); + for (var r = 0; r < YearListCell.ButtonRows; ++r) { + var buttonsRow = createElement("div", YearListCell.ClassNameMonthButtonsRow); + for (var c = 0; c < YearListCell.ButtonColumns; ++c) { + var month = c + r * YearListCell.ButtonColumns; + var button = createElement("button", YearListCell.ClassNameMonthButton, shortMonthLabels[month]); + button.dataset.month = month; + buttonsRow.appendChild(button); + this.monthButtons.push(button); + } + monthChooserElement.appendChild(buttonsRow); + } + this.element.appendChild(monthChooserElement); + + /** + * @type {!boolean} + * @private + */ + this._selected = false; + /** + * @type {!number} + * @private + */ + this._height = 0; +} + +YearListCell.prototype = Object.create(ListCell.prototype); + +YearListCell.Height = hasInaccuratePointingDevice() ? 31 : 25; +YearListCell.BorderBottomWidth = 1; +YearListCell.ButtonRows = 3; +YearListCell.ButtonColumns = 4; +YearListCell.SelectedHeight = hasInaccuratePointingDevice() ? 127 : 121; +YearListCell.ClassNameYearListCell = "year-list-cell"; +YearListCell.ClassNameLabel = "label"; +YearListCell.ClassNameMonthChooser = "month-chooser"; +YearListCell.ClassNameMonthButtonsRow = "month-buttons-row"; +YearListCell.ClassNameMonthButton = "month-button"; +YearListCell.ClassNameHighlighted = "highlighted"; + +YearListCell._recycleBin = []; + +/** + * @return {!Array} + * @override + */ +YearListCell.prototype._recycleBin = function() { + return YearListCell._recycleBin; +}; + +/** + * @param {!number} row + */ +YearListCell.prototype.reset = function(row) { + this.row = row; + this.label.textContent = row + 1; + for (var i = 0; i < this.monthButtons.length; ++i) { + this.monthButtons[i].classList.remove(YearListCell.ClassNameHighlighted); + } + this.show(); +}; + +/** + * @return {!number} The height in pixels. + */ +YearListCell.prototype.height = function() { + return this._height; +}; + +/** + * @param {!number} height Height in pixels. + */ +YearListCell.prototype.setHeight = function(height) { + if (this._height === height) + return; + this._height = height; + this.element.style.height = this._height + "px"; +}; + +/** + * @constructor + * @extends ListView + * @param {!Month} minimumMonth + * @param {!Month} maximumMonth + */ +function YearListView(minimumMonth, maximumMonth) { + ListView.call(this); + this.element.classList.add("year-list-view"); + + /** + * @type {?Month} + */ + this.highlightedMonth = null; + /** + * @type {!Month} + * @const + * @protected + */ + this._minimumMonth = minimumMonth; + /** + * @type {!Month} + * @const + * @protected + */ + this._maximumMonth = maximumMonth; + + this.scrollView.minimumContentOffset = (this._minimumMonth.year - 1) * YearListCell.Height; + this.scrollView.maximumContentOffset = (this._maximumMonth.year - 1) * YearListCell.Height + YearListCell.SelectedHeight; + + /** + * @type {!Object} + * @const + * @protected + */ + this._runningAnimators = {}; + /** + * @type {!Array} + * @const + * @protected + */ + this._animatingRows = []; + /** + * @type {!boolean} + * @protected + */ + this._ignoreMouseOutUntillNextMouseOver = false; + + /** + * @type {!ScrubbyScrollBar} + * @const + */ + this.scrubbyScrollBar = new ScrubbyScrollBar(this.scrollView); + this.scrubbyScrollBar.attachTo(this); + + this.element.addEventListener("mouseover", this.onMouseOver, false); + this.element.addEventListener("mouseout", this.onMouseOut, false); + this.element.addEventListener("keydown", this.onKeyDown, false); + this.element.addEventListener("touchstart", this.onTouchStart, false); +} + +YearListView.prototype = Object.create(ListView.prototype); + +YearListView.Height = YearListCell.SelectedHeight - 1; +YearListView.EventTypeYearListViewDidHide = "yearListViewDidHide"; +YearListView.EventTypeYearListViewDidSelectMonth = "yearListViewDidSelectMonth"; + +/** + * @param {?Event} event + */ +YearListView.prototype.onTouchStart = function(event) { + var touch = event.touches[0]; + var monthButtonElement = enclosingNodeOrSelfWithClass(touch.target, YearListCell.ClassNameMonthButton); + if (!monthButtonElement) + return; + var cellElement = enclosingNodeOrSelfWithClass(monthButtonElement, YearListCell.ClassNameYearListCell); + var cell = cellElement.$view; + this.highlightMonth(new Month(cell.row + 1, parseInt(monthButtonElement.dataset.month, 10))); +}; + +/** + * @param {?Event} event + */ +YearListView.prototype.onMouseOver = function(event) { + var monthButtonElement = enclosingNodeOrSelfWithClass(event.target, YearListCell.ClassNameMonthButton); + if (!monthButtonElement) + return; + var cellElement = enclosingNodeOrSelfWithClass(monthButtonElement, YearListCell.ClassNameYearListCell); + var cell = cellElement.$view; + this.highlightMonth(new Month(cell.row + 1, parseInt(monthButtonElement.dataset.month, 10))); + this._ignoreMouseOutUntillNextMouseOver = false; +}; + +/** + * @param {?Event} event + */ +YearListView.prototype.onMouseOut = function(event) { + if (this._ignoreMouseOutUntillNextMouseOver) + return; + var monthButtonElement = enclosingNodeOrSelfWithClass(event.target, YearListCell.ClassNameMonthButton); + if (!monthButtonElement) { + this.dehighlightMonth(); + } +}; + +/** + * @param {!number} width Width in pixels. + * @override + */ +YearListView.prototype.setWidth = function(width) { + ListView.prototype.setWidth.call(this, width - this.scrubbyScrollBar.element.offsetWidth); + this.element.style.width = width + "px"; +}; + +/** + * @param {!number} height Height in pixels. + * @override + */ +YearListView.prototype.setHeight = function(height) { + ListView.prototype.setHeight.call(this, height); + this.scrubbyScrollBar.setHeight(height); +}; + +/** + * @enum {number} + */ +YearListView.RowAnimationDirection = { + Opening: 0, + Closing: 1 +}; + +/** + * @param {!number} row + * @param {!YearListView.RowAnimationDirection} direction + */ +YearListView.prototype._animateRow = function(row, direction) { + var fromValue = direction === YearListView.RowAnimationDirection.Closing ? YearListCell.SelectedHeight : YearListCell.Height; + var oldAnimator = this._runningAnimators[row]; + if (oldAnimator) { + oldAnimator.stop(); + fromValue = oldAnimator.currentValue; + } + var cell = this.cellAtRow(row); + var animator = new TransitionAnimator(); + animator.step = this.onCellHeightAnimatorStep; + animator.setFrom(fromValue); + animator.setTo(direction === YearListView.RowAnimationDirection.Opening ? YearListCell.SelectedHeight : YearListCell.Height); + animator.timingFunction = AnimationTimingFunction.EaseInOut; + animator.duration = 300; + animator.row = row; + animator.on(Animator.EventTypeDidAnimationStop, this.onCellHeightAnimatorDidStop); + this._runningAnimators[row] = animator; + this._animatingRows.push(row); + this._animatingRows.sort(); + animator.start(); +}; + +/** + * @param {?Animator} animator + */ +YearListView.prototype.onCellHeightAnimatorDidStop = function(animator) { + delete this._runningAnimators[animator.row]; + var index = this._animatingRows.indexOf(animator.row); + this._animatingRows.splice(index, 1); +}; + +/** + * @param {!Animator} animator + */ +YearListView.prototype.onCellHeightAnimatorStep = function(animator) { + var cell = this.cellAtRow(animator.row); + if (cell) + cell.setHeight(animator.currentValue); + this.updateCells(); +}; + +/** + * @param {?Event} event + */ +YearListView.prototype.onClick = function(event) { + var oldSelectedRow = this.selectedRow; + ListView.prototype.onClick.call(this, event); + var year = this.selectedRow + 1; + if (this.selectedRow !== oldSelectedRow) { + var month = this.highlightedMonth ? this.highlightedMonth.month : 0; + this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, this, new Month(year, month)); + this.scrollView.scrollTo(this.selectedRow * YearListCell.Height, true); + } else { + var monthButton = enclosingNodeOrSelfWithClass(event.target, YearListCell.ClassNameMonthButton); + if (!monthButton) + return; + var month = parseInt(monthButton.dataset.month, 10); + this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, this, new Month(year, month)); + this.hide(); + } +}; + +/** + * @param {!number} scrollOffset + * @return {!number} + * @override + */ +YearListView.prototype.rowAtScrollOffset = function(scrollOffset) { + var remainingOffset = scrollOffset; + var lastAnimatingRow = 0; + var rowsWithIrregularHeight = this._animatingRows.slice(); + if (this.selectedRow > -1 && !this._runningAnimators[this.selectedRow]) { + rowsWithIrregularHeight.push(this.selectedRow); + rowsWithIrregularHeight.sort(); + } + for (var i = 0; i < rowsWithIrregularHeight.length; ++i) { + var row = rowsWithIrregularHeight[i]; + var animator = this._runningAnimators[row]; + var rowHeight = animator ? animator.currentValue : YearListCell.SelectedHeight; + if (remainingOffset <= (row - lastAnimatingRow) * YearListCell.Height) { + return lastAnimatingRow + Math.floor(remainingOffset / YearListCell.Height); + } + remainingOffset -= (row - lastAnimatingRow) * YearListCell.Height; + if (remainingOffset <= (rowHeight - YearListCell.Height)) + return row; + remainingOffset -= rowHeight - YearListCell.Height; + lastAnimatingRow = row; + } + return lastAnimatingRow + Math.floor(remainingOffset / YearListCell.Height); +}; + +/** + * @param {!number} row + * @return {!number} + * @override + */ +YearListView.prototype.scrollOffsetForRow = function(row) { + var scrollOffset = row * YearListCell.Height; + for (var i = 0; i < this._animatingRows.length; ++i) { + var animatingRow = this._animatingRows[i]; + if (animatingRow >= row) + break; + var animator = this._runningAnimators[animatingRow]; + scrollOffset += animator.currentValue - YearListCell.Height; + } + if (this.selectedRow > -1 && this.selectedRow < row && !this._runningAnimators[this.selectedRow]) { + scrollOffset += YearListCell.SelectedHeight - YearListCell.Height; + } + return scrollOffset; +}; + +/** + * @param {!number} row + * @return {!YearListCell} + * @override + */ +YearListView.prototype.prepareNewCell = function(row) { + var cell = YearListCell._recycleBin.pop() || new YearListCell(global.params.shortMonthLabels); + cell.reset(row); + cell.setSelected(this.selectedRow === row); + if (this.highlightedMonth && row === this.highlightedMonth.year - 1) { + cell.monthButtons[this.highlightedMonth.month].classList.add(YearListCell.ClassNameHighlighted); + } + for (var i = 0; i < cell.monthButtons.length; ++i) { + var month = new Month(row + 1, i); + cell.monthButtons[i].disabled = this._minimumMonth > month || this._maximumMonth < month; + } + var animator = this._runningAnimators[row]; + if (animator) + cell.setHeight(animator.currentValue); + else if (row === this.selectedRow) + cell.setHeight(YearListCell.SelectedHeight); + else + cell.setHeight(YearListCell.Height); + return cell; +}; + +/** + * @override + */ +YearListView.prototype.updateCells = function() { + var firstVisibleRow = this.firstVisibleRow(); + var lastVisibleRow = this.lastVisibleRow(); + console.assert(firstVisibleRow <= lastVisibleRow); + for (var c in this._cells) { + var cell = this._cells[c]; + if (cell.row < firstVisibleRow || cell.row > lastVisibleRow) + this.throwAwayCell(cell); + } + for (var i = firstVisibleRow; i <= lastVisibleRow; ++i) { + var cell = this._cells[i]; + if (cell) + cell.setPosition(this.scrollView.contentPositionForContentOffset(this.scrollOffsetForRow(cell.row))); + else + this.addCellIfNecessary(i); + } + this.setNeedsUpdateCells(false); +}; + +/** + * @override + */ +YearListView.prototype.deselect = function() { + if (this.selectedRow === ListView.NoSelection) + return; + var selectedCell = this._cells[this.selectedRow]; + if (selectedCell) + selectedCell.setSelected(false); + this._animateRow(this.selectedRow, YearListView.RowAnimationDirection.Closing); + this.selectedRow = ListView.NoSelection; + this.setNeedsUpdateCells(true); +}; + +YearListView.prototype.deselectWithoutAnimating = function() { + if (this.selectedRow === ListView.NoSelection) + return; + var selectedCell = this._cells[this.selectedRow]; + if (selectedCell) { + selectedCell.setSelected(false); + selectedCell.setHeight(YearListCell.Height); + } + this.selectedRow = ListView.NoSelection; + this.setNeedsUpdateCells(true); +}; + +/** + * @param {!number} row + * @override + */ +YearListView.prototype.select = function(row) { + if (this.selectedRow === row) + return; + this.deselect(); + if (row === ListView.NoSelection) + return; + this.selectedRow = row; + if (this.selectedRow !== ListView.NoSelection) { + var selectedCell = this._cells[this.selectedRow]; + this._animateRow(this.selectedRow, YearListView.RowAnimationDirection.Opening); + if (selectedCell) + selectedCell.setSelected(true); + var month = this.highlightedMonth ? this.highlightedMonth.month : 0; + this.highlightMonth(new Month(this.selectedRow + 1, month)); + } + this.setNeedsUpdateCells(true); +}; + +/** + * @param {!number} row + */ +YearListView.prototype.selectWithoutAnimating = function(row) { + if (this.selectedRow === row) + return; + this.deselectWithoutAnimating(); + if (row === ListView.NoSelection) + return; + this.selectedRow = row; + if (this.selectedRow !== ListView.NoSelection) { + var selectedCell = this._cells[this.selectedRow]; + if (selectedCell) { + selectedCell.setSelected(true); + selectedCell.setHeight(YearListCell.SelectedHeight); + } + var month = this.highlightedMonth ? this.highlightedMonth.month : 0; + this.highlightMonth(new Month(this.selectedRow + 1, month)); + } + this.setNeedsUpdateCells(true); +}; + +/** + * @param {!Month} month + * @return {?HTMLButtonElement} + */ +YearListView.prototype.buttonForMonth = function(month) { + if (!month) + return null; + var row = month.year - 1; + var cell = this.cellAtRow(row); + if (!cell) + return null; + return cell.monthButtons[month.month]; +}; + +YearListView.prototype.dehighlightMonth = function() { + if (!this.highlightedMonth) + return; + var monthButton = this.buttonForMonth(this.highlightedMonth); + if (monthButton) { + monthButton.classList.remove(YearListCell.ClassNameHighlighted); + } + this.highlightedMonth = null; +}; + +/** + * @param {!Month} month + */ +YearListView.prototype.highlightMonth = function(month) { + if (this.highlightedMonth && this.highlightedMonth.equals(month)) + return; + this.dehighlightMonth(); + this.highlightedMonth = month; + if (!this.highlightedMonth) + return; + var monthButton = this.buttonForMonth(this.highlightedMonth); + if (monthButton) { + monthButton.classList.add(YearListCell.ClassNameHighlighted); + } +}; + +/** + * @param {!Month} month + */ +YearListView.prototype.show = function(month) { + this._ignoreMouseOutUntillNextMouseOver = true; + + this.scrollToRow(month.year - 1, false); + this.selectWithoutAnimating(month.year - 1); + this.highlightMonth(month); +}; + +YearListView.prototype.hide = function() { + this.dispatchEvent(YearListView.EventTypeYearListViewDidHide, this); +}; + +/** + * @param {!Month} month + */ +YearListView.prototype._moveHighlightTo = function(month) { + this.highlightMonth(month); + this.select(this.highlightedMonth.year - 1); + + this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, this, month); + this.scrollView.scrollTo(this.selectedRow * YearListCell.Height, true); + return true; +}; + +/** + * @param {?Event} event + */ +YearListView.prototype.onKeyDown = function(event) { + var key = event.keyIdentifier; + var eventHandled = false; + if (key == "U+0054") // 't' key. + eventHandled = this._moveHighlightTo(Month.createFromToday()); + else if (this.highlightedMonth) { + if (global.params.isLocaleRTL ? key == "Right" : key == "Left") + eventHandled = this._moveHighlightTo(this.highlightedMonth.previous()); + else if (key == "Up") + eventHandled = this._moveHighlightTo(this.highlightedMonth.previous(YearListCell.ButtonColumns)); + else if (global.params.isLocaleRTL ? key == "Left" : key == "Right") + eventHandled = this._moveHighlightTo(this.highlightedMonth.next()); + else if (key == "Down") + eventHandled = this._moveHighlightTo(this.highlightedMonth.next(YearListCell.ButtonColumns)); + else if (key == "PageUp") + eventHandled = this._moveHighlightTo(this.highlightedMonth.previous(MonthsPerYear)); + else if (key == "PageDown") + eventHandled = this._moveHighlightTo(this.highlightedMonth.next(MonthsPerYear)); + else if (key == "Enter") { + this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, this, this.highlightedMonth); + this.hide(); + eventHandled = true; + } + } else if (key == "Up") { + this.scrollView.scrollBy(-YearListCell.Height, true); + eventHandled = true; + } else if (key == "Down") { + this.scrollView.scrollBy(YearListCell.Height, true); + eventHandled = true; + } else if (key == "PageUp") { + this.scrollView.scrollBy(-this.scrollView.height(), true); + eventHandled = true; + } else if (key == "PageDown") { + this.scrollView.scrollBy(this.scrollView.height(), true); + eventHandled = true; + } + + if (eventHandled) { + event.stopPropagation(); + event.preventDefault(); + } +}; + +/** + * @constructor + * @extends View + * @param {!Month} minimumMonth + * @param {!Month} maximumMonth + */ +function MonthPopupView(minimumMonth, maximumMonth) { + View.call(this, createElement("div", MonthPopupView.ClassNameMonthPopupView)); + + /** + * @type {!YearListView} + * @const + */ + this.yearListView = new YearListView(minimumMonth, maximumMonth); + this.yearListView.attachTo(this); + + /** + * @type {!boolean} + */ + this.isVisible = false; + + this.element.addEventListener("click", this.onClick, false); +} + +MonthPopupView.prototype = Object.create(View.prototype); + +MonthPopupView.ClassNameMonthPopupView = "month-popup-view"; + +MonthPopupView.prototype.show = function(initialMonth, calendarTableRect) { + this.isVisible = true; + document.body.appendChild(this.element); + this.yearListView.setWidth(calendarTableRect.width - 2); + this.yearListView.setHeight(YearListView.Height); + if (global.params.isLocaleRTL) + this.yearListView.element.style.right = calendarTableRect.x + "px"; + else + this.yearListView.element.style.left = calendarTableRect.x + "px"; + this.yearListView.element.style.top = calendarTableRect.y + "px"; + this.yearListView.show(initialMonth); + this.yearListView.element.focus(); +}; + +MonthPopupView.prototype.hide = function() { + if (!this.isVisible) + return; + this.isVisible = false; + this.element.parentNode.removeChild(this.element); + this.yearListView.hide(); +}; + +/** + * @param {?Event} event + */ +MonthPopupView.prototype.onClick = function(event) { + if (event.target !== this.element) + return; + this.hide(); +}; + +/** + * @constructor + * @extends View + * @param {!number} maxWidth Maximum width in pixels. + */ +function MonthPopupButton(maxWidth) { + View.call(this, createElement("button", MonthPopupButton.ClassNameMonthPopupButton)); + + /** + * @type {!Element} + * @const + */ + this.labelElement = createElement("span", MonthPopupButton.ClassNameMonthPopupButtonLabel, "-----"); + this.element.appendChild(this.labelElement); + + /** + * @type {!Element} + * @const + */ + this.disclosureTriangleIcon = createElement("span", MonthPopupButton.ClassNameDisclosureTriangle); + this.disclosureTriangleIcon.innerHTML = "<svg width='7' height='5'><polygon points='0,1 7,1 3.5,5' style='fill:#000000;' /></svg>"; + this.element.appendChild(this.disclosureTriangleIcon); + + /** + * @type {!boolean} + * @protected + */ + this._useShortMonth = this._shouldUseShortMonth(maxWidth); + this.element.style.maxWidth = maxWidth + "px"; + + this.element.addEventListener("click", this.onClick, false); +} + +MonthPopupButton.prototype = Object.create(View.prototype); + +MonthPopupButton.ClassNameMonthPopupButton = "month-popup-button"; +MonthPopupButton.ClassNameMonthPopupButtonLabel = "month-popup-button-label"; +MonthPopupButton.ClassNameDisclosureTriangle = "disclosure-triangle"; +MonthPopupButton.EventTypeButtonClick = "buttonClick"; + +/** + * @param {!number} maxWidth Maximum available width in pixels. + * @return {!boolean} + */ +MonthPopupButton.prototype._shouldUseShortMonth = function(maxWidth) { + document.body.appendChild(this.element); + var month = Month.Maximum; + for (var i = 0; i < MonthsPerYear; ++i) { + this.labelElement.textContent = month.toLocaleString(); + if (this.element.offsetWidth > maxWidth) + return true; + month = month.previous(); + } + document.body.removeChild(this.element); + return false; +}; + +/** + * @param {!Month} month + */ +MonthPopupButton.prototype.setCurrentMonth = function(month) { + this.labelElement.textContent = this._useShortMonth ? month.toShortLocaleString() : month.toLocaleString(); +}; + +/** + * @param {?Event} event + */ +MonthPopupButton.prototype.onClick = function(event) { + this.dispatchEvent(MonthPopupButton.EventTypeButtonClick, this); +}; + +/** + * @constructor + * @extends View + */ +function CalendarNavigationButton() { + View.call(this, createElement("button", CalendarNavigationButton.ClassNameCalendarNavigationButton)); + /** + * @type {number} Threshold for starting repeating clicks in milliseconds. + */ + this.repeatingClicksStartingThreshold = CalendarNavigationButton.DefaultRepeatingClicksStartingThreshold; + /** + * @type {number} Interval between reapeating clicks in milliseconds. + */ + this.reapeatingClicksInterval = CalendarNavigationButton.DefaultRepeatingClicksInterval; + /** + * @type {?number} The ID for the timeout that triggers the repeating clicks. + */ + this._timer = null; + this.element.addEventListener("click", this.onClick, false); + this.element.addEventListener("mousedown", this.onMouseDown, false); + this.element.addEventListener("touchstart", this.onTouchStart, false); +}; + +CalendarNavigationButton.prototype = Object.create(View.prototype); + +CalendarNavigationButton.DefaultRepeatingClicksStartingThreshold = 600; +CalendarNavigationButton.DefaultRepeatingClicksInterval = 300; +CalendarNavigationButton.LeftMargin = 4; +CalendarNavigationButton.Width = 24; +CalendarNavigationButton.ClassNameCalendarNavigationButton = "calendar-navigation-button"; +CalendarNavigationButton.EventTypeButtonClick = "buttonClick"; +CalendarNavigationButton.EventTypeRepeatingButtonClick = "repeatingButtonClick"; + +/** + * @param {!boolean} disabled + */ +CalendarNavigationButton.prototype.setDisabled = function(disabled) { + this.element.disabled = disabled; +}; + +/** + * @param {?Event} event + */ +CalendarNavigationButton.prototype.onClick = function(event) { + this.dispatchEvent(CalendarNavigationButton.EventTypeButtonClick, this); +}; + +/** + * @param {?Event} event + */ +CalendarNavigationButton.prototype.onTouchStart = function(event) { + if (this._timer !== null) + return; + this._timer = setTimeout(this.onRepeatingClick, this.repeatingClicksStartingThreshold); + window.addEventListener("touchend", this.onWindowTouchEnd, false); +}; + +/** + * @param {?Event} event + */ +CalendarNavigationButton.prototype.onWindowTouchEnd = function(event) { + if (this._timer === null) + return; + clearTimeout(this._timer); + this._timer = null; + window.removeEventListener("touchend", this.onWindowMouseUp, false); +}; + +/** + * @param {?Event} event + */ +CalendarNavigationButton.prototype.onMouseDown = function(event) { + if (this._timer !== null) + return; + this._timer = setTimeout(this.onRepeatingClick, this.repeatingClicksStartingThreshold); + window.addEventListener("mouseup", this.onWindowMouseUp, false); +}; + +/** + * @param {?Event} event + */ +CalendarNavigationButton.prototype.onWindowMouseUp = function(event) { + if (this._timer === null) + return; + clearTimeout(this._timer); + this._timer = null; + window.removeEventListener("mouseup", this.onWindowMouseUp, false); +}; + +/** + * @param {?Event} event + */ +CalendarNavigationButton.prototype.onRepeatingClick = function(event) { + this.dispatchEvent(CalendarNavigationButton.EventTypeRepeatingButtonClick, this); + this._timer = setTimeout(this.onRepeatingClick, this.reapeatingClicksInterval); +}; + +/** + * @constructor + * @extends View + * @param {!CalendarPicker} calendarPicker + */ +function CalendarHeaderView(calendarPicker) { + View.call(this, createElement("div", CalendarHeaderView.ClassNameCalendarHeaderView)); + this.calendarPicker = calendarPicker; + this.calendarPicker.on(CalendarPicker.EventTypeCurrentMonthChanged, this.onCurrentMonthChanged); + + var titleElement = createElement("div", CalendarHeaderView.ClassNameCalendarTitle); + this.element.appendChild(titleElement); + + /** + * @type {!MonthPopupButton} + */ + this.monthPopupButton = new MonthPopupButton(this.calendarPicker.calendarTableView.width() - CalendarTableView.BorderWidth * 2 - CalendarNavigationButton.Width * 3 - CalendarNavigationButton.LeftMargin * 2); + this.monthPopupButton.attachTo(titleElement); + + /** + * @type {!CalendarNavigationButton} + * @const + */ + this._previousMonthButton = new CalendarNavigationButton(); + this._previousMonthButton.attachTo(this); + this._previousMonthButton.on(CalendarNavigationButton.EventTypeButtonClick, this.onNavigationButtonClick); + this._previousMonthButton.on(CalendarNavigationButton.EventTypeRepeatingButtonClick, this.onNavigationButtonClick); + + /** + * @type {!CalendarNavigationButton} + * @const + */ + this._todayButton = new CalendarNavigationButton(); + this._todayButton.attachTo(this); + this._todayButton.on(CalendarNavigationButton.EventTypeButtonClick, this.onNavigationButtonClick); + this._todayButton.element.classList.add(CalendarHeaderView.ClassNameTodayButton); + var monthContainingToday = Month.createFromToday(); + this._todayButton.setDisabled(monthContainingToday < this.calendarPicker.minimumMonth || monthContainingToday > this.calendarPicker.maximumMonth); + + /** + * @type {!CalendarNavigationButton} + * @const + */ + this._nextMonthButton = new CalendarNavigationButton(); + this._nextMonthButton.attachTo(this); + this._nextMonthButton.on(CalendarNavigationButton.EventTypeButtonClick, this.onNavigationButtonClick); + this._nextMonthButton.on(CalendarNavigationButton.EventTypeRepeatingButtonClick, this.onNavigationButtonClick); + + if (global.params.isLocaleRTL) { + this._nextMonthButton.element.innerHTML = CalendarHeaderView._BackwardTriangle; + this._previousMonthButton.element.innerHTML = CalendarHeaderView._ForwardTriangle; + } else { + this._nextMonthButton.element.innerHTML = CalendarHeaderView._ForwardTriangle; + this._previousMonthButton.element.innerHTML = CalendarHeaderView._BackwardTriangle; + } +} + +CalendarHeaderView.prototype = Object.create(View.prototype); + +CalendarHeaderView.Height = 24; +CalendarHeaderView.BottomMargin = 10; +CalendarHeaderView._ForwardTriangle = "<svg width='4' height='7'><polygon points='0,7 0,0, 4,3.5' style='fill:#6e6e6e;' /></svg>"; +CalendarHeaderView._BackwardTriangle = "<svg width='4' height='7'><polygon points='0,3.5 4,7 4,0' style='fill:#6e6e6e;' /></svg>"; +CalendarHeaderView.ClassNameCalendarHeaderView = "calendar-header-view"; +CalendarHeaderView.ClassNameCalendarTitle = "calendar-title"; +CalendarHeaderView.ClassNameTodayButton = "today-button"; + +CalendarHeaderView.prototype.onCurrentMonthChanged = function() { + this.monthPopupButton.setCurrentMonth(this.calendarPicker.currentMonth()); + this._previousMonthButton.setDisabled(this.disabled || this.calendarPicker.currentMonth() <= this.calendarPicker.minimumMonth); + this._nextMonthButton.setDisabled(this.disabled || this.calendarPicker.currentMonth() >= this.calendarPicker.maximumMonth); +}; + +CalendarHeaderView.prototype.onNavigationButtonClick = function(sender) { + if (sender === this._previousMonthButton) + this.calendarPicker.setCurrentMonth(this.calendarPicker.currentMonth().previous(), CalendarPicker.NavigationBehavior.WithAnimation); + else if (sender === this._nextMonthButton) + this.calendarPicker.setCurrentMonth(this.calendarPicker.currentMonth().next(), CalendarPicker.NavigationBehavior.WithAnimation); + else + this.calendarPicker.selectRangeContainingDay(Day.createFromToday()); +}; + +/** + * @param {!boolean} disabled + */ +CalendarHeaderView.prototype.setDisabled = function(disabled) { + this.disabled = disabled; + this.monthPopupButton.element.disabled = this.disabled; + this._previousMonthButton.setDisabled(this.disabled || this.calendarPicker.currentMonth() <= this.calendarPicker.minimumMonth); + this._nextMonthButton.setDisabled(this.disabled || this.calendarPicker.currentMonth() >= this.calendarPicker.maximumMonth); + var monthContainingToday = Month.createFromToday(); + this._todayButton.setDisabled(this.disabled || monthContainingToday < this.calendarPicker.minimumMonth || monthContainingToday > this.calendarPicker.maximumMonth); +}; + +/** + * @constructor + * @extends ListCell + */ +function DayCell() { + ListCell.call(this); + this.element.classList.add(DayCell.ClassNameDayCell); + this.element.style.width = DayCell.Width + "px"; + this.element.style.height = DayCell.Height + "px"; + this.element.style.lineHeight = (DayCell.Height - DayCell.PaddingSize * 2) + "px"; + /** + * @type {?Day} + */ + this.day = null; +}; + +DayCell.prototype = Object.create(ListCell.prototype); + +DayCell.Width = 34; +DayCell.Height = hasInaccuratePointingDevice() ? 34 : 20; +DayCell.PaddingSize = 1; +DayCell.ClassNameDayCell = "day-cell"; +DayCell.ClassNameHighlighted = "highlighted"; +DayCell.ClassNameDisabled = "disabled"; +DayCell.ClassNameCurrentMonth = "current-month"; +DayCell.ClassNameToday = "today"; + +DayCell._recycleBin = []; + +DayCell.recycleOrCreate = function() { + return DayCell._recycleBin.pop() || new DayCell(); +}; + +/** + * @return {!Array} + * @override + */ +DayCell.prototype._recycleBin = function() { + return DayCell._recycleBin; +}; + +/** + * @override + */ +DayCell.prototype.throwAway = function() { + ListCell.prototype.throwAway.call(this); + this.day = null; +}; + +/** + * @param {!boolean} highlighted + */ +DayCell.prototype.setHighlighted = function(highlighted) { + if (highlighted) + this.element.classList.add(DayCell.ClassNameHighlighted); + else + this.element.classList.remove(DayCell.ClassNameHighlighted); +}; + +/** + * @param {!boolean} disabled + */ +DayCell.prototype.setDisabled = function(disabled) { + if (disabled) + this.element.classList.add(DayCell.ClassNameDisabled); + else + this.element.classList.remove(DayCell.ClassNameDisabled); +}; + +/** + * @param {!boolean} selected + */ +DayCell.prototype.setIsInCurrentMonth = function(selected) { + if (selected) + this.element.classList.add(DayCell.ClassNameCurrentMonth); + else + this.element.classList.remove(DayCell.ClassNameCurrentMonth); +}; + +/** + * @param {!boolean} selected + */ +DayCell.prototype.setIsToday = function(selected) { + if (selected) + this.element.classList.add(DayCell.ClassNameToday); + else + this.element.classList.remove(DayCell.ClassNameToday); +}; + +/** + * @param {!Day} day + */ +DayCell.prototype.reset = function(day) { + this.day = day; + this.element.textContent = localizeNumber(this.day.date.toString()); + this.show(); +}; + +/** + * @constructor + * @extends ListCell + */ +function WeekNumberCell() { + ListCell.call(this); + this.element.classList.add(WeekNumberCell.ClassNameWeekNumberCell); + this.element.style.width = (WeekNumberCell.Width - WeekNumberCell.SeparatorWidth) + "px"; + this.element.style.height = WeekNumberCell.Height + "px"; + this.element.style.lineHeight = (WeekNumberCell.Height - WeekNumberCell.PaddingSize * 2) + "px"; + /** + * @type {?Week} + */ + this.week = null; +}; + +WeekNumberCell.prototype = Object.create(ListCell.prototype); + +WeekNumberCell.Width = 48; +WeekNumberCell.Height = DayCell.Height; +WeekNumberCell.SeparatorWidth = 1; +WeekNumberCell.PaddingSize = 1; +WeekNumberCell.ClassNameWeekNumberCell = "week-number-cell"; +WeekNumberCell.ClassNameHighlighted = "highlighted"; +WeekNumberCell.ClassNameDisabled = "disabled"; + +WeekNumberCell._recycleBin = []; + +/** + * @return {!Array} + * @override + */ +WeekNumberCell.prototype._recycleBin = function() { + return WeekNumberCell._recycleBin; +}; + +/** + * @return {!WeekNumberCell} + */ +WeekNumberCell.recycleOrCreate = function() { + return WeekNumberCell._recycleBin.pop() || new WeekNumberCell(); +}; + +/** + * @param {!Week} week + */ +WeekNumberCell.prototype.reset = function(week) { + this.week = week; + this.element.textContent = localizeNumber(this.week.week.toString()); + this.show(); +}; + +/** + * @override + */ +WeekNumberCell.prototype.throwAway = function() { + ListCell.prototype.throwAway.call(this); + this.week = null; +}; + +WeekNumberCell.prototype.setHighlighted = function(highlighted) { + if (highlighted) + this.element.classList.add(WeekNumberCell.ClassNameHighlighted); + else + this.element.classList.remove(WeekNumberCell.ClassNameHighlighted); +}; + +WeekNumberCell.prototype.setDisabled = function(disabled) { + if (disabled) + this.element.classList.add(WeekNumberCell.ClassNameDisabled); + else + this.element.classList.remove(WeekNumberCell.ClassNameDisabled); +}; + +/** + * @constructor + * @extends View + * @param {!boolean} hasWeekNumberColumn + */ +function CalendarTableHeaderView(hasWeekNumberColumn) { + View.call(this, createElement("div", "calendar-table-header-view")); + if (hasWeekNumberColumn) { + var weekNumberLabelElement = createElement("div", "week-number-label", global.params.weekLabel); + weekNumberLabelElement.style.width = WeekNumberCell.Width + "px"; + this.element.appendChild(weekNumberLabelElement); + } + for (var i = 0; i < DaysPerWeek; ++i) { + var weekDayNumber = (global.params.weekStartDay + i) % DaysPerWeek; + var labelElement = createElement("div", "week-day-label", global.params.dayLabels[weekDayNumber]); + labelElement.style.width = DayCell.Width + "px"; + this.element.appendChild(labelElement); + if (getLanguage() === "ja") { + if (weekDayNumber === 0) + labelElement.style.color = "red"; + else if (weekDayNumber === 6) + labelElement.style.color = "blue"; + } + } +} + +CalendarTableHeaderView.prototype = Object.create(View.prototype); + +CalendarTableHeaderView.Height = 25; + +/** + * @constructor + * @extends ListCell + */ +function CalendarRowCell() { + ListCell.call(this); + this.element.classList.add(CalendarRowCell.ClassNameCalendarRowCell); + this.element.style.height = CalendarRowCell.Height + "px"; + + /** + * @type {!Array} + * @protected + */ + this._dayCells = []; + /** + * @type {!number} + */ + this.row = 0; + /** + * @type {?CalendarTableView} + */ + this.calendarTableView = null; +} + +CalendarRowCell.prototype = Object.create(ListCell.prototype); + +CalendarRowCell.Height = DayCell.Height; +CalendarRowCell.ClassNameCalendarRowCell = "calendar-row-cell"; + +CalendarRowCell._recycleBin = []; + +/** + * @return {!Array} + * @override + */ +CalendarRowCell.prototype._recycleBin = function() { + return CalendarRowCell._recycleBin; +}; + +/** + * @param {!number} row + * @param {!CalendarTableView} calendarTableView + */ +CalendarRowCell.prototype.reset = function(row, calendarTableView) { + this.row = row; + this.calendarTableView = calendarTableView; + if (this.calendarTableView.hasWeekNumberColumn) { + var middleDay = this.calendarTableView.dayAtColumnAndRow(3, row); + var week = Week.createFromDay(middleDay); + this.weekNumberCell = this.calendarTableView.prepareNewWeekNumberCell(week); + this.weekNumberCell.attachTo(this); + } + var day = calendarTableView.dayAtColumnAndRow(0, row); + for (var i = 0; i < DaysPerWeek; ++i) { + var dayCell = this.calendarTableView.prepareNewDayCell(day); + dayCell.attachTo(this); + this._dayCells.push(dayCell); + day = day.next(); + } + this.show(); +}; + +/** + * @override + */ +CalendarRowCell.prototype.throwAway = function() { + ListCell.prototype.throwAway.call(this); + if (this.weekNumberCell) + this.calendarTableView.throwAwayWeekNumberCell(this.weekNumberCell); + this._dayCells.forEach(this.calendarTableView.throwAwayDayCell, this.calendarTableView); + this._dayCells.length = 0; +}; + +/** + * @constructor + * @extends ListView + * @param {!CalendarPicker} calendarPicker + */ +function CalendarTableView(calendarPicker) { + ListView.call(this); + this.element.classList.add(CalendarTableView.ClassNameCalendarTableView); + this.element.tabIndex = 0; + + /** + * @type {!boolean} + * @const + */ + this.hasWeekNumberColumn = calendarPicker.type === "week"; + /** + * @type {!CalendarPicker} + * @const + */ + this.calendarPicker = calendarPicker; + /** + * @type {!Object} + * @const + */ + this._dayCells = {}; + var headerView = new CalendarTableHeaderView(this.hasWeekNumberColumn); + headerView.attachTo(this, this.scrollView); + + if (this.hasWeekNumberColumn) { + this.setWidth(DayCell.Width * DaysPerWeek + WeekNumberCell.Width); + /** + * @type {?Array} + * @const + */ + this._weekNumberCells = []; + } else { + this.setWidth(DayCell.Width * DaysPerWeek); + } + + /** + * @type {!boolean} + * @protected + */ + this._ignoreMouseOutUntillNextMouseOver = false; + + this.element.addEventListener("click", this.onClick, false); + this.element.addEventListener("mouseover", this.onMouseOver, false); + this.element.addEventListener("mouseout", this.onMouseOut, false); + + // You shouldn't be able to use the mouse wheel to scroll. + this.scrollView.element.removeEventListener("mousewheel", this.scrollView.onMouseWheel, false); + // You shouldn't be able to do gesture scroll. + this.scrollView.element.removeEventListener("touchstart", this.scrollView.onTouchStart, false); +} + +CalendarTableView.prototype = Object.create(ListView.prototype); + +CalendarTableView.BorderWidth = 1; +CalendarTableView.ClassNameCalendarTableView = "calendar-table-view"; + +/** + * @param {!number} scrollOffset + * @return {!number} + */ +CalendarTableView.prototype.rowAtScrollOffset = function(scrollOffset) { + return Math.floor(scrollOffset / CalendarRowCell.Height); +}; + +/** + * @param {!number} row + * @return {!number} + */ +CalendarTableView.prototype.scrollOffsetForRow = function(row) { + return row * CalendarRowCell.Height; +}; + +/** + * @param {?Event} event + */ +CalendarTableView.prototype.onClick = function(event) { + if (this.hasWeekNumberColumn) { + var weekNumberCellElement = enclosingNodeOrSelfWithClass(event.target, WeekNumberCell.ClassNameWeekNumberCell); + if (weekNumberCellElement) { + var weekNumberCell = weekNumberCellElement.$view; + this.calendarPicker.selectRangeContainingDay(weekNumberCell.week.firstDay()); + return; + } + } + var dayCellElement = enclosingNodeOrSelfWithClass(event.target, DayCell.ClassNameDayCell); + if (!dayCellElement) + return; + var dayCell = dayCellElement.$view; + this.calendarPicker.selectRangeContainingDay(dayCell.day); +}; + +/** + * @param {?Event} event + */ +CalendarTableView.prototype.onMouseOver = function(event) { + if (this.hasWeekNumberColumn) { + var weekNumberCellElement = enclosingNodeOrSelfWithClass(event.target, WeekNumberCell.ClassNameWeekNumberCell); + if (weekNumberCellElement) { + var weekNumberCell = weekNumberCellElement.$view; + this.calendarPicker.highlightRangeContainingDay(weekNumberCell.week.firstDay()); + this._ignoreMouseOutUntillNextMouseOver = false; + return; + } + } + var dayCellElement = enclosingNodeOrSelfWithClass(event.target, DayCell.ClassNameDayCell); + if (!dayCellElement) + return; + var dayCell = dayCellElement.$view; + this.calendarPicker.highlightRangeContainingDay(dayCell.day); + this._ignoreMouseOutUntillNextMouseOver = false; +}; + +/** + * @param {?Event} event + */ +CalendarTableView.prototype.onMouseOut = function(event) { + if (this._ignoreMouseOutUntillNextMouseOver) + return; + var dayCellElement = enclosingNodeOrSelfWithClass(event.target, DayCell.ClassNameDayCell); + if (!dayCellElement) { + this.calendarPicker.highlightRangeContainingDay(null); + } +}; + +/** + * @param {!number} row + * @return {!CalendarRowCell} + */ +CalendarTableView.prototype.prepareNewCell = function(row) { + var cell = CalendarRowCell._recycleBin.pop() || new CalendarRowCell(); + cell.reset(row, this); + return cell; +}; + +/** + * @return {!number} Height in pixels. + */ +CalendarTableView.prototype.height = function() { + return this.scrollView.height() + CalendarTableHeaderView.Height + CalendarTableView.BorderWidth * 2; +}; + +/** + * @param {!number} height Height in pixels. + */ +CalendarTableView.prototype.setHeight = function(height) { + this.scrollView.setHeight(height - CalendarTableHeaderView.Height - CalendarTableView.BorderWidth * 2); +}; + +/** + * @param {!Month} month + * @param {!boolean} animate + */ +CalendarTableView.prototype.scrollToMonth = function(month, animate) { + var rowForFirstDayInMonth = this.columnAndRowForDay(month.firstDay()).row; + this.scrollView.scrollTo(this.scrollOffsetForRow(rowForFirstDayInMonth), animate); +}; + +/** + * @param {!number} column + * @param {!number} row + * @return {!Day} + */ +CalendarTableView.prototype.dayAtColumnAndRow = function(column, row) { + var daysSinceMinimum = row * DaysPerWeek + column + global.params.weekStartDay - CalendarTableView._MinimumDayWeekDay; + return Day.createFromValue(daysSinceMinimum * MillisecondsPerDay + CalendarTableView._MinimumDayValue); +}; + +CalendarTableView._MinimumDayValue = Day.Minimum.valueOf(); +CalendarTableView._MinimumDayWeekDay = Day.Minimum.weekDay(); + +/** + * @param {!Day} day + * @return {!Object} Object with properties column and row. + */ +CalendarTableView.prototype.columnAndRowForDay = function(day) { + var daysSinceMinimum = (day.valueOf() - CalendarTableView._MinimumDayValue) / MillisecondsPerDay; + var offset = daysSinceMinimum + CalendarTableView._MinimumDayWeekDay - global.params.weekStartDay; + var row = Math.floor(offset / DaysPerWeek); + var column = offset - row * DaysPerWeek; + return { + column: column, + row: row + }; +}; + +CalendarTableView.prototype.updateCells = function() { + ListView.prototype.updateCells.call(this); + + var selection = this.calendarPicker.selection(); + var firstDayInSelection; + var lastDayInSelection; + if (selection) { + firstDayInSelection = selection.firstDay().valueOf(); + lastDayInSelection = selection.lastDay().valueOf(); + } else { + firstDayInSelection = Infinity; + lastDayInSelection = Infinity; + } + var highlight = this.calendarPicker.highlight(); + var firstDayInHighlight; + var lastDayInHighlight; + if (highlight) { + firstDayInHighlight = highlight.firstDay().valueOf(); + lastDayInHighlight = highlight.lastDay().valueOf(); + } else { + firstDayInHighlight = Infinity; + lastDayInHighlight = Infinity; + } + var currentMonth = this.calendarPicker.currentMonth(); + var firstDayInCurrentMonth = currentMonth.firstDay().valueOf(); + var lastDayInCurrentMonth = currentMonth.lastDay().valueOf(); + for (var dayString in this._dayCells) { + var dayCell = this._dayCells[dayString]; + var day = dayCell.day; + dayCell.setIsToday(Day.createFromToday().equals(day)); + dayCell.setSelected(day >= firstDayInSelection && day <= lastDayInSelection); + dayCell.setHighlighted(day >= firstDayInHighlight && day <= lastDayInHighlight); + dayCell.setIsInCurrentMonth(day >= firstDayInCurrentMonth && day <= lastDayInCurrentMonth); + dayCell.setDisabled(!this.calendarPicker.isValidDay(day)); + } + if (this.hasWeekNumberColumn) { + for (var weekString in this._weekNumberCells) { + var weekNumberCell = this._weekNumberCells[weekString]; + var week = weekNumberCell.week; + weekNumberCell.setSelected(selection && selection.equals(week)); + weekNumberCell.setHighlighted(highlight && highlight.equals(week)); + weekNumberCell.setDisabled(!this.calendarPicker.isValid(week)); + } + } +}; + +/** + * @param {!Day} day + * @return {!DayCell} + */ +CalendarTableView.prototype.prepareNewDayCell = function(day) { + var dayCell = DayCell.recycleOrCreate(); + dayCell.reset(day); + this._dayCells[dayCell.day.toString()] = dayCell; + return dayCell; +}; + +/** + * @param {!Week} week + * @return {!WeekNumberCell} + */ +CalendarTableView.prototype.prepareNewWeekNumberCell = function(week) { + var weekNumberCell = WeekNumberCell.recycleOrCreate(); + weekNumberCell.reset(week); + this._weekNumberCells[weekNumberCell.week.toString()] = weekNumberCell; + return weekNumberCell; +}; + +/** + * @param {!DayCell} dayCell + */ +CalendarTableView.prototype.throwAwayDayCell = function(dayCell) { + delete this._dayCells[dayCell.day.toString()]; + dayCell.throwAway(); +}; + +/** + * @param {!WeekNumberCell} weekNumberCell + */ +CalendarTableView.prototype.throwAwayWeekNumberCell = function(weekNumberCell) { + delete this._weekNumberCells[weekNumberCell.week.toString()]; + weekNumberCell.throwAway(); +}; + +/** + * @constructor + * @extends View + * @param {!Object} config + */ +function CalendarPicker(type, config) { + View.call(this, createElement("div", CalendarPicker.ClassNameCalendarPicker)); + this.element.classList.add(CalendarPicker.ClassNamePreparing); + + /** + * @type {!string} + * @const + */ + this.type = type; + if (this.type === "week") + this._dateTypeConstructor = Week; + else if (this.type === "month") + this._dateTypeConstructor = Month; + else + this._dateTypeConstructor = Day; + /** + * @type {!Object} + * @const + */ + this.config = {}; + this._setConfig(config); + /** + * @type {!Month} + * @const + */ + this.minimumMonth = Month.createFromDay(this.config.minimum.firstDay()); + /** + * @type {!Month} + * @const + */ + this.maximumMonth = Month.createFromDay(this.config.maximum.lastDay()); + if (global.params.isLocaleRTL) + this.element.classList.add("rtl"); + /** + * @type {!CalendarTableView} + * @const + */ + this.calendarTableView = new CalendarTableView(this); + this.calendarTableView.hasNumberColumn = this.type === "week"; + /** + * @type {!CalendarHeaderView} + * @const + */ + this.calendarHeaderView = new CalendarHeaderView(this); + this.calendarHeaderView.monthPopupButton.on(MonthPopupButton.EventTypeButtonClick, this.onMonthPopupButtonClick); + /** + * @type {!MonthPopupView} + * @const + */ + this.monthPopupView = new MonthPopupView(this.minimumMonth, this.maximumMonth); + this.monthPopupView.yearListView.on(YearListView.EventTypeYearListViewDidSelectMonth, this.onYearListViewDidSelectMonth); + this.monthPopupView.yearListView.on(YearListView.EventTypeYearListViewDidHide, this.onYearListViewDidHide); + this.calendarHeaderView.attachTo(this); + this.calendarTableView.attachTo(this); + /** + * @type {!Month} + * @protected + */ + this._currentMonth = new Month(NaN, NaN); + /** + * @type {?DateType} + * @protected + */ + this._selection = null; + /** + * @type {?DateType} + * @protected + */ + this._highlight = null; + this.calendarTableView.element.addEventListener("keydown", this.onCalendarTableKeyDown, false); + document.body.addEventListener("keydown", this.onBodyKeyDown, false); + + window.addEventListener("resize", this.onWindowResize, false); + + /** + * @type {!number} + * @protected + */ + this._height = -1; + + var initialSelection = parseDateString(config.currentValue); + if (initialSelection) { + this.setCurrentMonth(Month.createFromDay(initialSelection.middleDay()), CalendarPicker.NavigationBehavior.None); + this.setSelection(initialSelection); + } else + this.setCurrentMonth(Month.createFromToday(), CalendarPicker.NavigationBehavior.None); +} + +CalendarPicker.prototype = Object.create(View.prototype); + +CalendarPicker.Padding = 10; +CalendarPicker.BorderWidth = 1; +CalendarPicker.ClassNameCalendarPicker = "calendar-picker"; +CalendarPicker.ClassNamePreparing = "preparing"; +CalendarPicker.EventTypeCurrentMonthChanged = "currentMonthChanged"; + +/** + * @param {!Event} event + */ +CalendarPicker.prototype.onWindowResize = function(event) { + this.element.classList.remove(CalendarPicker.ClassNamePreparing); + window.removeEventListener("resize", this.onWindowResize, false); +}; + +/** + * @param {!YearListView} sender + */ +CalendarPicker.prototype.onYearListViewDidHide = function(sender) { + this.monthPopupView.hide(); + this.calendarHeaderView.setDisabled(false); + this.adjustHeight(); +}; + +/** + * @param {!YearListView} sender + * @param {!Month} month + */ +CalendarPicker.prototype.onYearListViewDidSelectMonth = function(sender, month) { + this.setCurrentMonth(month, CalendarPicker.NavigationBehavior.None); +}; + +/** + * @param {!View|Node} parent + * @param {?View|Node=} before + * @override + */ +CalendarPicker.prototype.attachTo = function(parent, before) { + View.prototype.attachTo.call(this, parent, before); + this.calendarTableView.element.focus(); +}; + +CalendarPicker.prototype.cleanup = function() { + window.removeEventListener("resize", this.onWindowResize, false); + this.calendarTableView.element.removeEventListener("keydown", this.onBodyKeyDown, false); + // Month popup view might be attached to document.body. + this.monthPopupView.hide(); +}; + +/** + * @param {?MonthPopupButton} sender + */ +CalendarPicker.prototype.onMonthPopupButtonClick = function(sender) { + var clientRect = this.calendarTableView.element.getBoundingClientRect(); + var calendarTableRect = new Rectangle(clientRect.left + document.body.scrollLeft, clientRect.top + document.body.scrollTop, clientRect.width, clientRect.height); + this.monthPopupView.show(this.currentMonth(), calendarTableRect); + this.calendarHeaderView.setDisabled(true); + this.adjustHeight(); +}; + +CalendarPicker.prototype._setConfig = function(config) { + this.config.minimum = (typeof config.min !== "undefined" && config.min) ? parseDateString(config.min) : this._dateTypeConstructor.Minimum; + this.config.maximum = (typeof config.max !== "undefined" && config.max) ? parseDateString(config.max) : this._dateTypeConstructor.Maximum; + this.config.minimumValue = this.config.minimum.valueOf(); + this.config.maximumValue = this.config.maximum.valueOf(); + this.config.step = (typeof config.step !== undefined) ? Number(config.step) : this._dateTypeConstructor.DefaultStep; + this.config.stepBase = (typeof config.stepBase !== "undefined") ? Number(config.stepBase) : this._dateTypeConstructor.DefaultStepBase; +}; + +/** + * @return {!Month} + */ +CalendarPicker.prototype.currentMonth = function() { + return this._currentMonth; +}; + +/** + * @enum {number} + */ +CalendarPicker.NavigationBehavior = { + None: 0, + WithAnimation: 1 +}; + +/** + * @param {!Month} month + * @param {!CalendarPicker.NavigationBehavior} animate + */ +CalendarPicker.prototype.setCurrentMonth = function(month, behavior) { + if (month > this.maximumMonth) + month = this.maximumMonth; + else if (month < this.minimumMonth) + month = this.minimumMonth; + if (this._currentMonth.equals(month)) + return; + this._currentMonth = month; + this.calendarTableView.scrollToMonth(this._currentMonth, behavior === CalendarPicker.NavigationBehavior.WithAnimation); + this.adjustHeight(); + this.calendarTableView.setNeedsUpdateCells(true); + this.dispatchEvent(CalendarPicker.EventTypeCurrentMonthChanged, { + target: this + }); +}; + +CalendarPicker.prototype.adjustHeight = function() { + var rowForFirstDayInMonth = this.calendarTableView.columnAndRowForDay(this._currentMonth.firstDay()).row; + var rowForLastDayInMonth = this.calendarTableView.columnAndRowForDay(this._currentMonth.lastDay()).row; + var numberOfRows = rowForLastDayInMonth - rowForFirstDayInMonth + 1; + var calendarTableViewHeight = CalendarTableHeaderView.Height + numberOfRows * DayCell.Height + CalendarTableView.BorderWidth * 2; + var height = (this.monthPopupView.isVisible ? YearListView.Height : calendarTableViewHeight) + CalendarHeaderView.Height + CalendarHeaderView.BottomMargin + CalendarPicker.Padding * 2 + CalendarPicker.BorderWidth * 2; + this.setHeight(height); +}; + +CalendarPicker.prototype.selection = function() { + return this._selection; +}; + +CalendarPicker.prototype.highlight = function() { + return this._highlight; +}; + +/** + * @return {!Day} + */ +CalendarPicker.prototype.firstVisibleDay = function() { + var firstVisibleRow = this.calendarTableView.columnAndRowForDay(this.currentMonth().firstDay()).row; + var firstVisibleDay = this.calendarTableView.dayAtColumnAndRow(0, firstVisibleRow); + if (!firstVisibleDay) + firstVisibleDay = Day.Minimum; + return firstVisibleDay; +}; + +/** + * @return {!Day} + */ +CalendarPicker.prototype.lastVisibleDay = function() { + var lastVisibleRow = this.calendarTableView.columnAndRowForDay(this.currentMonth().lastDay()).row; + var lastVisibleDay = this.calendarTableView.dayAtColumnAndRow(DaysPerWeek - 1, lastVisibleRow); + if (!lastVisibleDay) + lastVisibleDay = Day.Maximum; + return lastVisibleDay; +}; + +/** + * @param {?Day} day + */ +CalendarPicker.prototype.selectRangeContainingDay = function(day) { + var selection = day ? this._dateTypeConstructor.createFromDay(day) : null; + this.setSelection(selection); +}; + +/** + * @param {?Day} day + */ +CalendarPicker.prototype.highlightRangeContainingDay = function(day) { + var highlight = day ? this._dateTypeConstructor.createFromDay(day) : null; + this._setHighlight(highlight); +}; + +/** + * @param {?DateType} dayOrWeekOrMonth + */ +CalendarPicker.prototype.setSelection = function(dayOrWeekOrMonth) { + if (!this._selection && !dayOrWeekOrMonth) + return; + if (this._selection && this._selection.equals(dayOrWeekOrMonth)) + return; + var firstDayInSelection = dayOrWeekOrMonth.firstDay(); + var lastDayInSelection = dayOrWeekOrMonth.lastDay(); + var candidateCurrentMonth = Month.createFromDay(firstDayInSelection); + if (this.firstVisibleDay() > lastDayInSelection || this.lastVisibleDay() < firstDayInSelection) { + // Change current month if the selection is not visible at all. + this.setCurrentMonth(candidateCurrentMonth, CalendarPicker.NavigationBehavior.WithAnimation); + } else if (this.firstVisibleDay() < firstDayInSelection || this.lastVisibleDay() > lastDayInSelection) { + // If the selection is partly visible, only change the current month if + // doing so will make the whole selection visible. + var firstVisibleRow = this.calendarTableView.columnAndRowForDay(candidateCurrentMonth.firstDay()).row; + var firstVisibleDay = this.calendarTableView.dayAtColumnAndRow(0, firstVisibleRow); + var lastVisibleRow = this.calendarTableView.columnAndRowForDay(candidateCurrentMonth.lastDay()).row; + var lastVisibleDay = this.calendarTableView.dayAtColumnAndRow(DaysPerWeek - 1, lastVisibleRow); + if (firstDayInSelection >= firstVisibleDay && lastDayInSelection <= lastVisibleDay) + this.setCurrentMonth(candidateCurrentMonth, CalendarPicker.NavigationBehavior.WithAnimation); + } + this._setHighlight(dayOrWeekOrMonth); + if (!this.isValid(dayOrWeekOrMonth)) + return; + this._selection = dayOrWeekOrMonth; + this.calendarTableView.setNeedsUpdateCells(true); + window.pagePopupController.setValue(this._selection.toString()); +}; + +/** + * @param {?DateType} dayOrWeekOrMonth + */ +CalendarPicker.prototype._setHighlight = function(dayOrWeekOrMonth) { + if (!this._highlight && !dayOrWeekOrMonth) + return; + if (!dayOrWeekOrMonth && !this._highlight) + return; + if (this._highlight && this._highlight.equals(dayOrWeekOrMonth)) + return; + this._highlight = dayOrWeekOrMonth; + this.calendarTableView.setNeedsUpdateCells(true); +}; + +/** + * @param {!number} value + * @return {!boolean} + */ +CalendarPicker.prototype._stepMismatch = function(value) { + var nextAllowedValue = Math.ceil((value - this.config.stepBase) / this.config.step) * this.config.step + this.config.stepBase; + return nextAllowedValue >= value + this._dateTypeConstructor.DefaultStep; +}; + +/** + * @param {!number} value + * @return {!boolean} + */ +CalendarPicker.prototype._outOfRange = function(value) { + return value < this.config.minimumValue || value > this.config.maximumValue; +}; + +/** + * @param {!DateType} dayOrWeekOrMonth + * @return {!boolean} + */ +CalendarPicker.prototype.isValid = function(dayOrWeekOrMonth) { + var value = dayOrWeekOrMonth.valueOf(); + return dayOrWeekOrMonth instanceof this._dateTypeConstructor && !this._outOfRange(value) && !this._stepMismatch(value); +}; + +/** + * @param {!Day} day + * @return {!boolean} + */ +CalendarPicker.prototype.isValidDay = function(day) { + return this.isValid(this._dateTypeConstructor.createFromDay(day)); +}; + +/** + * @param {!DateType} dateRange + * @return {!boolean} Returns true if the highlight was changed. + */ +CalendarPicker.prototype._moveHighlight = function(dateRange) { + if (!dateRange) + return false; + if (this._outOfRange(dateRange.valueOf())) + return false; + if (this.firstVisibleDay() > dateRange.middleDay() || this.lastVisibleDay() < dateRange.middleDay()) + this.setCurrentMonth(Month.createFromDay(dateRange.middleDay()), CalendarPicker.NavigationBehavior.WithAnimation); + this._setHighlight(dateRange); + return true; +}; + +/** + * @param {?Event} event + */ +CalendarPicker.prototype.onCalendarTableKeyDown = function(event) { + var key = event.keyIdentifier; + var eventHandled = false; + if (key == "U+0054") { // 't' key. + this.selectRangeContainingDay(Day.createFromToday()); + eventHandled = true; + } else if (key == "PageUp") { + var previousMonth = this.currentMonth().previous(); + if (previousMonth && previousMonth >= this.config.minimumValue) { + this.setCurrentMonth(previousMonth, CalendarPicker.NavigationBehavior.WithAnimation); + eventHandled = true; + } + } else if (key == "PageDown") { + var nextMonth = this.currentMonth().next(); + if (nextMonth && nextMonth >= this.config.minimumValue) { + this.setCurrentMonth(nextMonth, CalendarPicker.NavigationBehavior.WithAnimation); + eventHandled = true; + } + } else if (this._highlight) { + if (global.params.isLocaleRTL ? key == "Right" : key == "Left") { + eventHandled = this._moveHighlight(this._highlight.previous()); + } else if (key == "Up") { + eventHandled = this._moveHighlight(this._highlight.previous(this.type === "date" ? DaysPerWeek : 1)); + } else if (global.params.isLocaleRTL ? key == "Left" : key == "Right") { + eventHandled = this._moveHighlight(this._highlight.next()); + } else if (key == "Down") { + eventHandled = this._moveHighlight(this._highlight.next(this.type === "date" ? DaysPerWeek : 1)); + } else if (key == "Enter") { + this.setSelection(this._highlight); + } + } else if (key == "Left" || key == "Up" || key == "Right" || key == "Down") { + // Highlight range near the middle. + this.highlightRangeContainingDay(this.currentMonth().middleDay()); + eventHandled = true; + } + + if (eventHandled) { + event.stopPropagation(); + event.preventDefault(); + } +}; + +/** + * @return {!number} Width in pixels. + */ +CalendarPicker.prototype.width = function() { + return this.calendarTableView.width() + (CalendarTableView.BorderWidth + CalendarPicker.BorderWidth + CalendarPicker.Padding) * 2; +}; + +/** + * @return {!number} Height in pixels. + */ +CalendarPicker.prototype.height = function() { + return this._height; +}; + +/** + * @param {!number} height Height in pixels. + */ +CalendarPicker.prototype.setHeight = function(height) { + if (this._height === height) + return; + this._height = height; + resizeWindow(this.width(), this._height); + this.calendarTableView.setHeight(this._height - CalendarHeaderView.Height - CalendarHeaderView.BottomMargin - CalendarPicker.Padding * 2 - CalendarTableView.BorderWidth * 2); +}; + +/** + * @param {?Event} event + */ +CalendarPicker.prototype.onBodyKeyDown = function(event) { + var key = event.keyIdentifier; + var eventHandled = false; + var offset = 0; + switch (key) { + case "U+001B": // Esc key. + window.pagePopupController.closePopup(); + eventHandled = true; + break; + case "U+004D": // 'm' key. + offset = offset || 1; // Fall-through. + case "U+0059": // 'y' key. + offset = offset || MonthsPerYear; // Fall-through. + case "U+0044": // 'd' key. + offset = offset || MonthsPerYear * 10; + var oldFirstVisibleRow = this.calendarTableView.columnAndRowForDay(this.currentMonth().firstDay()).row; + this.setCurrentMonth(event.shiftKey ? this.currentMonth().previous(offset) : this.currentMonth().next(offset), CalendarPicker.NavigationBehavior.WithAnimation); + var newFirstVisibleRow = this.calendarTableView.columnAndRowForDay(this.currentMonth().firstDay()).row; + if (this._highlight) { + var highlightMiddleDay = this._highlight.middleDay(); + this.highlightRangeContainingDay(highlightMiddleDay.next((newFirstVisibleRow - oldFirstVisibleRow) * DaysPerWeek)); + } + eventHandled =true; + break; + } + if (eventHandled) { + event.stopPropagation(); + event.preventDefault(); + } +} + +if (window.dialogArguments) { + initialize(dialogArguments); +} else { + window.addEventListener("message", handleMessage, false); +} diff --git a/Source/web/resources/colorSuggestionPicker.css b/Source/web/resources/colorSuggestionPicker.css new file mode 100644 index 000000000..39a162bda --- /dev/null +++ b/Source/web/resources/colorSuggestionPicker.css @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +body { + -webkit-user-select: none; + background-color: white; + font: -webkit-small-control; + margin: 0; + overflow: hidden; +} + +#main { + background-color: white; + border: solid 1px #8899aa; + box-shadow: inset 2px 2px 2px white, + inset -2px -2px 1px rgba(0,0,0,0.1); + padding: 6px; + float: left; +} + +.color-swatch { + float: left; + width: 20px; + height: 20px; + margin: 1px; + padding: 0; + border: 1px solid #e0e0e0; + box-sizing: content-box; +} + +.color-swatch:focus { + border: 1px solid #000000; + outline: none; +} + +.color-swatch-container { + width: 100%; + max-height: 104px; + overflow: auto; + display: flex; + flex-flow: row wrap; + align-items: center; +} + +.other-color { + width: 100%; + margin: 4px 0 0 0; +} diff --git a/Source/web/resources/colorSuggestionPicker.js b/Source/web/resources/colorSuggestionPicker.js new file mode 100644 index 000000000..559b9e6dc --- /dev/null +++ b/Source/web/resources/colorSuggestionPicker.js @@ -0,0 +1,189 @@ +"use strict"; +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +var global = { + argumentsReceived: false, + params: null +}; + +/** + * @param {Event} event + */ +function handleMessage(event) { + initialize(JSON.parse(event.data)); + global.argumentsReceived = true; +} + +/** + * @param {!Object} args + */ +function initialize(args) { + global.params = args; + var main = $("main"); + main.innerHTML = ""; + var errorString = validateArguments(args); + if (errorString) { + main.textContent = "Internal error: " + errorString; + resizeWindow(main.offsetWidth, main.offsetHeight); + } else + new ColorPicker(main, args); +} + +// The DefaultColorPalette is used when the list of values are empty. +var DefaultColorPalette = ["#000000", "#404040", "#808080", "#c0c0c0", + "#ffffff", "#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", + "#4a86e8", "#0000ff", "#9900ff", "#ff00ff"]; + +function handleArgumentsTimeout() { + if (global.argumentsReceived) + return; + var args = { + values : DefaultColorPalette, + otherColorLabel: "Other..." + }; + initialize(args); +} + +/** + * @param {!Object} args + * @return {?string} An error message, or null if the argument has no errors. + */ +function validateArguments(args) { + if (!args.values) + return "No values."; + if (!args.otherColorLabel) + return "No otherColorLabel."; + return null; +} + +function ColorPicker(element, config) { + Picker.call(this, element, config); + this._config = config; + if (this._config.values.length === 0) + this._config.values = DefaultColorPalette; + this._container = null; + this._layout(); + document.body.addEventListener("keydown", this._handleKeyDown.bind(this)); + this._element.addEventListener("mousemove", this._handleMouseMove.bind(this)); + this._element.addEventListener("mousedown", this._handleMouseDown.bind(this)); +} +ColorPicker.prototype = Object.create(Picker.prototype); + +var SwatchBorderBoxWidth = 24; // keep in sync with CSS +var SwatchBorderBoxHeight = 24; // keep in sync with CSS +var SwatchesPerRow = 5; +var SwatchesMaxRow = 4; + +ColorPicker.prototype._layout = function() { + var container = createElement("div", "color-swatch-container"); + container.addEventListener("click", this._handleSwatchClick.bind(this), false); + for (var i = 0; i < this._config.values.length; ++i) { + var swatch = createElement("button", "color-swatch"); + swatch.dataset.index = i; + swatch.dataset.value = this._config.values[i]; + swatch.title = this._config.values[i]; + swatch.style.backgroundColor = this._config.values[i]; + container.appendChild(swatch); + } + var containerWidth = SwatchBorderBoxWidth * SwatchesPerRow; + if (this._config.values.length > SwatchesPerRow * SwatchesMaxRow) + containerWidth += getScrollbarWidth(); + container.style.width = containerWidth + "px"; + container.style.maxHeight = (SwatchBorderBoxHeight * SwatchesMaxRow) + "px"; + this._element.appendChild(container); + var otherButton = createElement("button", "other-color", this._config.otherColorLabel); + otherButton.addEventListener("click", this.chooseOtherColor.bind(this), false); + this._element.appendChild(otherButton); + this._container = container; + this._otherButton = otherButton; + var elementWidth = this._element.offsetWidth; + var elementHeight = this._element.offsetHeight; + resizeWindow(elementWidth, elementHeight); +}; + +ColorPicker.prototype.selectColorAtIndex = function(index) { + index = Math.max(Math.min(this._container.childNodes.length - 1, index), 0); + this._container.childNodes[index].focus(); +}; + +ColorPicker.prototype._handleMouseMove = function(event) { + if (event.target.classList.contains("color-swatch")) + event.target.focus(); +}; + +ColorPicker.prototype._handleMouseDown = function(event) { + // Prevent blur. + if (event.target.classList.contains("color-swatch")) + event.preventDefault(); +}; + +ColorPicker.prototype._handleKeyDown = function(event) { + var key = event.keyIdentifier; + if (key === "U+001B") // ESC + this.handleCancel(); + else if (key == "Left" || key == "Up" || key == "Right" || key == "Down") { + var selectedElement = document.activeElement; + var index = 0; + if (selectedElement.classList.contains("other-color")) { + if (key != "Right" && key != "Up") + return; + index = this._container.childNodes.length - 1; + } else if (selectedElement.classList.contains("color-swatch")) { + index = parseInt(selectedElement.dataset.index, 10); + switch (key) { + case "Left": + index--; + break; + case "Right": + index++; + break; + case "Up": + index -= SwatchesPerRow; + break; + case "Down": + index += SwatchesPerRow; + break; + } + if (index > this._container.childNodes.length - 1) { + this._otherButton.focus(); + return; + } + } + this.selectColorAtIndex(index); + } + event.preventDefault(); +}; + +ColorPicker.prototype._handleSwatchClick = function(event) { + if (event.target.classList.contains("color-swatch")) + this.submitValue(event.target.dataset.value); +}; + +if (window.dialogArguments) { + initialize(dialogArguments); +} else { + window.addEventListener("message", handleMessage, false); + window.setTimeout(handleArgumentsTimeout, 1000); +} diff --git a/Source/web/resources/pickerButton.css b/Source/web/resources/pickerButton.css new file mode 100644 index 000000000..b207a0da9 --- /dev/null +++ b/Source/web/resources/pickerButton.css @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +input[type='button'], +button { + -webkit-appearance: none; + -webkit-user-select: none; + background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede); + border: 1px solid rgba(0, 0, 0, 0.25); + border-radius: 2px; + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), + inset 0 1px 2px rgba(255, 255, 255, 0.75); + color: #444; + font: inherit; + text-shadow: 0 1px 0 rgb(240, 240, 240); + min-height: 2em; + min-width: 4em; + -webkit-padding-end: 10px; + -webkit-padding-start: 10px; + margin: 0; +} + +:enabled:hover:-webkit-any(button, input[type='button']) { + background-image: -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0); + border-color: rgba(0, 0, 0, 0.3); + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.95); + color: black; +} + +:enabled:active:-webkit-any(button, input[type='button']) { + background-image: -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7); + box-shadow: none; + text-shadow: none; +} + +:disabled:-webkit-any(button, input[type='button']) { + background-image: -webkit-linear-gradient(#f1f1f1, #f1f1f1 38%, #e6e6e6); + border-color: rgba(80, 80, 80, 0.2); + box-shadow: 0 1px 0 rgba(80, 80, 80, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.75); + color: #aaa; +} + +:enabled:focus:-webkit-any(button, input[type='button']) { + transition: border-color 200ms; + /* We use border color because it follows the border radius (unlike outline). + * This is particularly noticeable on mac. */ + border-color: rgb(77, 144, 254); + outline: none; +} diff --git a/Source/web/resources/pickerCommon.css b/Source/web/resources/pickerCommon.css new file mode 100644 index 000000000..696751a41 --- /dev/null +++ b/Source/web/resources/pickerCommon.css @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +body { + -webkit-user-select: none; + background-color: white; + font: -webkit-small-control; + margin: 0; + overflow: hidden; +} + +.rtl { + direction: rtl; +} diff --git a/Source/web/resources/pickerCommon.js b/Source/web/resources/pickerCommon.js new file mode 100644 index 000000000..7034329f8 --- /dev/null +++ b/Source/web/resources/pickerCommon.js @@ -0,0 +1,257 @@ +"use strict"; +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @param {!string} id + */ +function $(id) { + return document.getElementById(id); +} + +/** + * @param {!string} tagName + * @param {string=} opt_class + * @param {string=} opt_text + * @return {!Element} + */ +function createElement(tagName, opt_class, opt_text) { + var element = document.createElement(tagName); + if (opt_class) + element.setAttribute("class", opt_class); + if (opt_text) + element.appendChild(document.createTextNode(opt_text)); + return element; +} + +/** + * @constructor + * @param {!number|Rectangle|Object} xOrRect + * @param {!number} y + * @param {!number} width + * @param {!number} height + */ +function Rectangle(xOrRect, y, width, height) { + if (typeof xOrRect === "object") { + y = xOrRect.y; + width = xOrRect.width; + height = xOrRect.height; + xOrRect = xOrRect.x; + } + this.x = xOrRect; + this.y = y; + this.width = width; + this.height = height; +} + +Rectangle.prototype = { + get maxX() { return this.x + this.width; }, + get maxY() { return this.y + this.height; }, + toString: function() { return "Rectangle(" + this.x + "," + this.y + "," + this.width + "," + this.height + ")"; } +}; + +/** + * @param {!Rectangle} rect1 + * @param {!Rectangle} rect2 + * @return {?Rectangle} + */ +Rectangle.intersection = function(rect1, rect2) { + var x = Math.max(rect1.x, rect2.x); + var maxX = Math.min(rect1.maxX, rect2.maxX); + var y = Math.max(rect1.y, rect2.y); + var maxY = Math.min(rect1.maxY, rect2.maxY); + var width = maxX - x; + var height = maxY - y; + if (width < 0 || height < 0) + return null; + return new Rectangle(x, y, width, height); +}; + +/** + * @param {!number} width + * @param {!number} height + */ +function resizeWindow(width, height) { + setWindowRect(adjustWindowRect(width, height, width, height)); +} + +/** + * @param {!number} width + * @param {!number} height + * @param {?number} minWidth + * @param {?number} minHeight + * @return {!Rectangle} + */ +function adjustWindowRect(width, height, minWidth, minHeight) { + if (typeof minWidth !== "number") + minWidth = 0; + if (typeof minHeight !== "number") + minHeight = 0; + + var windowRect = new Rectangle(0, 0, width, height); + + if (!global.params.anchorRectInScreen) + return windowRect; + + var anchorRect = new Rectangle(global.params.anchorRectInScreen); + var availRect = new Rectangle(window.screen.availLeft, window.screen.availTop, window.screen.availWidth, window.screen.availHeight); + + _adjustWindowRectVertically(windowRect, availRect, anchorRect, minHeight); + _adjustWindowRectHorizontally(windowRect, availRect, anchorRect, minWidth); + + return windowRect; +} + +function _adjustWindowRectVertically(windowRect, availRect, anchorRect, minHeight) { + var availableSpaceAbove = anchorRect.y - availRect.y; + availableSpaceAbove = Math.max(0, Math.min(availRect.height, availableSpaceAbove)); + + var availableSpaceBelow = availRect.maxY - anchorRect.maxY; + availableSpaceBelow = Math.max(0, Math.min(availRect.height, availableSpaceBelow)); + + if (windowRect.height > availableSpaceBelow && availableSpaceBelow < availableSpaceAbove) { + windowRect.height = Math.min(windowRect.height, availableSpaceAbove); + windowRect.height = Math.max(windowRect.height, minHeight); + windowRect.y = anchorRect.y - windowRect.height; + } else { + windowRect.height = Math.min(windowRect.height, availableSpaceBelow); + windowRect.height = Math.max(windowRect.height, minHeight); + windowRect.y = anchorRect.maxY; + } + windowRect.y = Math.min(windowRect.y, availRect.maxY - windowRect.height); + windowRect.y = Math.max(windowRect.y, availRect.y); +} + +function _adjustWindowRectHorizontally(windowRect, availRect, anchorRect, minWidth) { + windowRect.width = Math.min(windowRect.width, availRect.width); + windowRect.width = Math.max(windowRect.width, minWidth); + windowRect.x = anchorRect.x; + if (global.params.isRTL) + windowRect.x += anchorRect.width - windowRect.width; + windowRect.x = Math.min(windowRect.x, availRect.maxX - windowRect.width); + windowRect.x = Math.max(windowRect.x, availRect.x); +} + +/** + * @param {!Rectangle} rect + */ +function setWindowRect(rect) { + if (window.frameElement) { + window.frameElement.style.width = rect.width + "px"; + window.frameElement.style.height = rect.height + "px"; + } else { + if (isWindowHidden()) { + window.moveTo(rect.x - window.screen.availLeft, rect.y - window.screen.availTop); + window.resizeTo(rect.width, rect.height); + } else { + window.resizeTo(rect.width, rect.height); + window.moveTo(rect.x - window.screen.availLeft, rect.y - window.screen.availTop); + } + } +} + +function hideWindow() { + resizeWindow(1, 1); +} + +/** + * @return {!boolean} + */ +function isWindowHidden() { + return window.innerWidth === 1 && window.innerHeight === 1; +} + +window.addEventListener("resize", function() { + if (isWindowHidden()) + window.dispatchEvent(new CustomEvent("didHide")); + else + window.dispatchEvent(new CustomEvent("didOpenPicker")); +}, false); + +/** + * @return {!number} + */ +function getScrollbarWidth() { + if (typeof window.scrollbarWidth === "undefined") { + var scrollDiv = document.createElement("div"); + scrollDiv.style.opacity = "0"; + scrollDiv.style.overflow = "scroll"; + scrollDiv.style.width = "50px"; + scrollDiv.style.height = "50px"; + document.body.appendChild(scrollDiv); + window.scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; + scrollDiv.parentNode.removeChild(scrollDiv); + } + return window.scrollbarWidth; +} + +/** + * @param {!string} className + * @return {?Element} + */ +function enclosingNodeOrSelfWithClass(selfNode, className) +{ + for (var node = selfNode; node && node !== selfNode.ownerDocument; node = node.parentNode) { + if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains(className)) + return node; + } + return null; +}; + +/** + * @constructor + * @param {!Element} element + * @param {!Object} config + */ +function Picker(element, config) { + this._element = element; + this._config = config; +} + +/** + * @enum {number} + */ +Picker.Actions = { + SetValue: 0, + Cancel: -1, + ChooseOtherColor: -2 +}; + +/** + * @param {!string} value + */ +Picker.prototype.submitValue = function(value) { + window.pagePopupController.setValue(value); + window.pagePopupController.closePopup(); +} + +Picker.prototype.handleCancel = function() { + window.pagePopupController.closePopup(); +} + +Picker.prototype.chooseOtherColor = function() { + window.pagePopupController.setValueAndClosePopup(Picker.Actions.ChooseOtherColor, ""); +} + +Picker.prototype.cleanup = function() {}; diff --git a/Source/web/resources/suggestionPicker.css b/Source/web/resources/suggestionPicker.css new file mode 100644 index 000000000..0281d0df5 --- /dev/null +++ b/Source/web/resources/suggestionPicker.css @@ -0,0 +1,56 @@ +.suggestion-list { + list-style: none; + padding: 0; + margin: 0; + font: -webkit-small-control; + border: 1px solid #7f9db9; + background-color: white; + overflow: hidden; +} + +.suggestion-list-entry { + white-space: nowrap; + height: 1.73em; + line-height: 1.73em; + -webkit-select: none; + cursor: default; +} + +.suggestion-list-entry:focus { + outline: none; +} + +.suggestion-list-entry .content { + padding: 0 4px; +} + +.suggestion-list-entry .label { + text-align: right; + color: #737373; + float: right; + padding: 0 4px 0 20px; +} + +.rtl .suggestion-list-entry .label { + float: left; + padding: 0 20px 0 4px; +} + +.suggestion-list-entry .title { + direction: ltr; + display: inline-block; +} + +.locale-rtl .suggestion-list-entry .title { + direction: rtl; +} + +.measuring-width .suggestion-list-entry .label { + float: none; + margin-right: 0; +} + +.suggestion-list .separator { + border-top: 1px solid #dcdcdc; + height: 0; +} diff --git a/Source/web/resources/suggestionPicker.js b/Source/web/resources/suggestionPicker.js new file mode 100644 index 000000000..2d4bada41 --- /dev/null +++ b/Source/web/resources/suggestionPicker.js @@ -0,0 +1,325 @@ +"use strict"; +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @constructor + * @param {!Element} element + * @param {!Object} config + */ +function SuggestionPicker(element, config) { + Picker.call(this, element, config); + this._isFocusByMouse = false; + this._containerElement = null; + this._setColors(); + this._layout(); + this._fixWindowSize(); + this._handleBodyKeyDownBound = this._handleBodyKeyDown.bind(this); + document.body.addEventListener("keydown", this._handleBodyKeyDownBound); + this._element.addEventListener("mouseout", this._handleMouseOut.bind(this), false); +}; +SuggestionPicker.prototype = Object.create(Picker.prototype); + +SuggestionPicker.NumberOfVisibleEntries = 20; + +// An entry needs to be at least this many pixels visible for it to be a visible entry. +SuggestionPicker.VisibleEntryThresholdHeight = 4; + +SuggestionPicker.ActionNames = { + OpenCalendarPicker: "openCalendarPicker" +}; + +SuggestionPicker.ListEntryClass = "suggestion-list-entry"; + +SuggestionPicker.validateConfig = function(config) { + if (config.showOtherDateEntry && !config.otherDateLabel) + return "No otherDateLabel."; + if (config.suggestionHighlightColor && !config.suggestionHighlightColor) + return "No suggestionHighlightColor."; + if (config.suggestionHighlightTextColor && !config.suggestionHighlightTextColor) + return "No suggestionHighlightTextColor."; + if (config.suggestionValues.length !== config.localizedSuggestionValues.length) + return "localizedSuggestionValues.length must equal suggestionValues.length."; + if (config.suggestionValues.length !== config.suggestionLabels.length) + return "suggestionLabels.length must equal suggestionValues.length."; + if (typeof config.inputWidth === "undefined") + return "No inputWidth."; + return null; +}; + +SuggestionPicker.prototype._setColors = function() { + var text = "." + SuggestionPicker.ListEntryClass + ":focus {\ + background-color: " + this._config.suggestionHighlightColor + ";\ + color: " + this._config.suggestionHighlightTextColor + "; }"; + text += "." + SuggestionPicker.ListEntryClass + ":focus .label { color: " + this._config.suggestionHighlightTextColor + "; }"; + document.head.appendChild(createElement("style", null, text)); +}; + +SuggestionPicker.prototype.cleanup = function() { + document.body.removeEventListener("keydown", this._handleBodyKeyDownBound, false); +}; + +/** + * @param {!string} title + * @param {!string} label + * @param {!string} value + * @return {!Element} + */ +SuggestionPicker.prototype._createSuggestionEntryElement = function(title, label, value) { + var entryElement = createElement("li", SuggestionPicker.ListEntryClass); + entryElement.tabIndex = 0; + entryElement.dataset.value = value; + var content = createElement("span", "content"); + entryElement.appendChild(content); + var titleElement = createElement("span", "title", title); + content.appendChild(titleElement); + if (label) { + var labelElement = createElement("span", "label", label); + content.appendChild(labelElement); + } + entryElement.addEventListener("mouseover", this._handleEntryMouseOver.bind(this), false); + return entryElement; +}; + +/** + * @param {!string} title + * @param {!string} actionName + * @return {!Element} + */ +SuggestionPicker.prototype._createActionEntryElement = function(title, actionName) { + var entryElement = createElement("li", SuggestionPicker.ListEntryClass); + entryElement.tabIndex = 0; + entryElement.dataset.action = actionName; + var content = createElement("span", "content"); + entryElement.appendChild(content); + var titleElement = createElement("span", "title", title); + content.appendChild(titleElement); + entryElement.addEventListener("mouseover", this._handleEntryMouseOver.bind(this), false); + return entryElement; +}; + +/** +* @return {!number} +*/ +SuggestionPicker.prototype._measureMaxContentWidth = function() { + // To measure the required width, we first set the class to "measuring-width" which + // left aligns all the content including label. + this._containerElement.classList.add("measuring-width"); + var maxContentWidth = 0; + var contentElements = this._containerElement.getElementsByClassName("content"); + for (var i=0; i < contentElements.length; ++i) { + maxContentWidth = Math.max(maxContentWidth, contentElements[i].offsetWidth); + } + this._containerElement.classList.remove("measuring-width"); + return maxContentWidth; +}; + +SuggestionPicker.prototype._fixWindowSize = function() { + var ListBorder = 2; + var desiredWindowWidth = this._measureMaxContentWidth() + ListBorder; + if (typeof this._config.inputWidth === "number") + desiredWindowWidth = Math.max(this._config.inputWidth, desiredWindowWidth); + var totalHeight = ListBorder; + var maxHeight = 0; + var entryCount = 0; + for (var i = 0; i < this._containerElement.childNodes.length; ++i) { + var node = this._containerElement.childNodes[i]; + if (node.classList.contains(SuggestionPicker.ListEntryClass)) + entryCount++; + totalHeight += node.offsetHeight; + if (maxHeight === 0 && entryCount == SuggestionPicker.NumberOfVisibleEntries) + maxHeight = totalHeight; + } + var desiredWindowHeight = totalHeight; + if (maxHeight !== 0 && totalHeight > maxHeight) { + this._containerElement.style.maxHeight = (maxHeight - ListBorder) + "px"; + desiredWindowWidth += getScrollbarWidth(); + desiredWindowHeight = maxHeight; + this._containerElement.style.overflowY = "scroll"; + } + + var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, desiredWindowWidth, 0); + this._containerElement.style.height = (windowRect.height - ListBorder) + "px"; + setWindowRect(windowRect); +}; + +SuggestionPicker.prototype._layout = function() { + if (this._config.isRTL) + this._element.classList.add("rtl"); + if (this._config.isLocaleRTL) + this._element.classList.add("locale-rtl"); + this._containerElement = createElement("ul", "suggestion-list"); + this._containerElement.addEventListener("click", this._handleEntryClick.bind(this), false); + for (var i = 0; i < this._config.suggestionValues.length; ++i) { + this._containerElement.appendChild(this._createSuggestionEntryElement(this._config.localizedSuggestionValues[i], this._config.suggestionLabels[i], this._config.suggestionValues[i])); + } + if (this._config.showOtherDateEntry) { + // Add separator + var separator = createElement("div", "separator"); + this._containerElement.appendChild(separator); + + // Add "Other..." entry + var otherEntry = this._createActionEntryElement(this._config.otherDateLabel, SuggestionPicker.ActionNames.OpenCalendarPicker); + this._containerElement.appendChild(otherEntry); + } + this._element.appendChild(this._containerElement); +}; + +/** + * @param {!Element} entry + */ +SuggestionPicker.prototype.selectEntry = function(entry) { + if (typeof entry.dataset.value !== "undefined") { + this.submitValue(entry.dataset.value); + } else if (entry.dataset.action === SuggestionPicker.ActionNames.OpenCalendarPicker) { + window.addEventListener("didHide", SuggestionPicker._handleWindowDidHide, false); + hideWindow(); + } +}; + +SuggestionPicker._handleWindowDidHide = function() { + openCalendarPicker(); + window.removeEventListener("didHide", SuggestionPicker._handleWindowDidHide); +}; + +/** + * @param {!Event} event + */ +SuggestionPicker.prototype._handleEntryClick = function(event) { + var entry = enclosingNodeOrSelfWithClass(event.target, SuggestionPicker.ListEntryClass); + if (!entry) + return; + this.selectEntry(entry); + event.preventDefault(); +}; + +/** + * @return {?Element} + */ +SuggestionPicker.prototype._findFirstVisibleEntry = function() { + var scrollTop = this._containerElement.scrollTop; + var childNodes = this._containerElement.childNodes; + for (var i = 0; i < childNodes.length; ++i) { + var node = childNodes[i]; + if (node.nodeType !== Node.ELEMENT_NODE || !node.classList.contains(SuggestionPicker.ListEntryClass)) + continue; + if (node.offsetTop + node.offsetHeight - scrollTop > SuggestionPicker.VisibleEntryThresholdHeight) + return node; + } + return null; +}; + +/** + * @return {?Element} + */ +SuggestionPicker.prototype._findLastVisibleEntry = function() { + var scrollBottom = this._containerElement.scrollTop + this._containerElement.offsetHeight; + var childNodes = this._containerElement.childNodes; + for (var i = childNodes.length - 1; i >= 0; --i){ + var node = childNodes[i]; + if (node.nodeType !== Node.ELEMENT_NODE || !node.classList.contains(SuggestionPicker.ListEntryClass)) + continue; + if (scrollBottom - node.offsetTop > SuggestionPicker.VisibleEntryThresholdHeight) + return node; + } + return null; +}; + +/** + * @param {!Event} event + */ +SuggestionPicker.prototype._handleBodyKeyDown = function(event) { + var eventHandled = false; + var key = event.keyIdentifier; + if (key === "U+001B") { // ESC + this.handleCancel(); + eventHandled = true; + } else if (key == "Up") { + if (document.activeElement && document.activeElement.classList.contains(SuggestionPicker.ListEntryClass)) { + for (var node = document.activeElement.previousElementSibling; node; node = node.previousElementSibling) { + if (node.classList.contains(SuggestionPicker.ListEntryClass)) { + this._isFocusByMouse = false; + node.focus(); + break; + } + } + } else { + this._element.querySelector("." + SuggestionPicker.ListEntryClass + ":last-child").focus(); + } + eventHandled = true; + } else if (key == "Down") { + if (document.activeElement && document.activeElement.classList.contains(SuggestionPicker.ListEntryClass)) { + for (var node = document.activeElement.nextElementSibling; node; node = node.nextElementSibling) { + if (node.classList.contains(SuggestionPicker.ListEntryClass)) { + this._isFocusByMouse = false; + node.focus(); + break; + } + } + } else { + this._element.querySelector("." + SuggestionPicker.ListEntryClass + ":first-child").focus(); + } + eventHandled = true; + } else if (key === "Enter") { + this.selectEntry(document.activeElement); + eventHandled = true; + } else if (key === "PageUp") { + this._containerElement.scrollTop -= this._containerElement.clientHeight; + // Scrolling causes mouseover event to be called and that tries to move the focus too. + // To prevent flickering we won't focus if the current focus was caused by the mouse. + if (!this._isFocusByMouse) + this._findFirstVisibleEntry().focus(); + eventHandled = true; + } else if (key === "PageDown") { + this._containerElement.scrollTop += this._containerElement.clientHeight; + if (!this._isFocusByMouse) + this._findLastVisibleEntry().focus(); + eventHandled = true; + } + if (eventHandled) + event.preventDefault(); +}; + +/** + * @param {!Event} event + */ +SuggestionPicker.prototype._handleEntryMouseOver = function(event) { + var entry = enclosingNodeOrSelfWithClass(event.target, SuggestionPicker.ListEntryClass); + if (!entry) + return; + this._isFocusByMouse = true; + entry.focus(); + event.preventDefault(); +}; + +/** + * @param {!Event} event + */ +SuggestionPicker.prototype._handleMouseOut = function(event) { + if (!document.activeElement.classList.contains(SuggestionPicker.ListEntryClass)) + return; + this._isFocusByMouse = false; + document.activeElement.blur(); + event.preventDefault(); +}; diff --git a/Source/web/scripts/make-file-arrays.py b/Source/web/scripts/make-file-arrays.py new file mode 100755 index 000000000..cfb41f303 --- /dev/null +++ b/Source/web/scripts/make-file-arrays.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +# Copyright (C) 2012 Google Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Usage: make-file-arrays.py [--condition=condition-string] --out-h=<header-file-name> --out-cpp=<cpp-file-name> <input-file>... + +import os.path +import re +import sys +from optparse import OptionParser + + +def make_variable_name_and_read(file_name): + result = re.match(r"([\w\d_]+)\.([\w\d_]+)", os.path.basename(file_name)) + if not result: + print "Invalid input file name:", os.path.basename(file_name) + sys.exit(1) + variable_name = result.group(1)[0].lower() + result.group(1)[1:] + result.group(2).capitalize() + file = open(file_name, "rb") + content = file.read() + file.close() + return (variable_name, content) + + +def strip_whitespace_and_comments(file_name, content): + result = re.match(r".*\.([^.]+)", file_name) + if not result: + print "The file name has no extension:", file_name + sys.exit(1) + extension = result.group(1).lower() + multi_line_comment = re.compile(r"/\*.*?\*/", re.MULTILINE | re.DOTALL) + single_line_comment = re.compile(r"//.*$", re.MULTILINE) + repeating_space = re.compile(r"[ \t]+", re.MULTILINE) + leading_space = re.compile(r"^[ \t]+", re.MULTILINE) + trailing_space = re.compile(r"[ \t]+$", re.MULTILINE) + empty_line = re.compile(r"\n+") + if extension == "js": + content = multi_line_comment.sub("", content) + content = single_line_comment.sub("", content) + content = repeating_space.sub(" ", content) + content = leading_space.sub("", content) + content = trailing_space.sub("", content) + content = empty_line.sub("\n", content) + elif extension == "css": + content = multi_line_comment.sub("", content) + content = repeating_space.sub(" ", content) + content = leading_space.sub("", content) + content = trailing_space.sub("", content) + content = empty_line.sub("\n", content) + return content + + +def main(): + parser = OptionParser() + parser.add_option("--out-h", dest="out_header") + parser.add_option("--out-cpp", dest="out_cpp") + parser.add_option("--condition", dest="flag") + (options, args) = parser.parse_args() + if len(args) < 1: + parser.error("Need one or more input files") + if not options.out_header: + parser.error("Need to specify --out-h=filename") + if not options.out_cpp: + parser.error("Need to specify --out-cpp=filename") + + if options.flag: + options.flag = options.flag.replace(" AND ", " && ") + options.flag = options.flag.replace(" OR ", " || ") + + header_file = open(options.out_header, "w") + if options.flag: + header_file.write("#if " + options.flag + "\n") + header_file.write("namespace WebKit {\n") + + cpp_file = open(options.out_cpp, "w") + cpp_file.write("#include \"config.h\"\n") + cpp_file.write("#include \"" + os.path.basename(options.out_header) + "\"\n") + if options.flag: + cpp_file.write("#if " + options.flag + "\n") + cpp_file.write("namespace WebKit {\n") + + for file_name in args: + (variable_name, content) = make_variable_name_and_read(file_name) + content = strip_whitespace_and_comments(file_name, content) + size = len(content) + header_file.write("extern const char %s[%d];\n" % (variable_name, size)) + cpp_file.write("const char %s[%d] = {\n" % (variable_name, size)) + for index in range(size): + char_code = ord(content[index]) + if char_code < 128: + cpp_file.write("%d" % char_code) + else: + cpp_file.write("'\\x%02x'" % char_code) + cpp_file.write("," if index != len(content) - 1 else "};\n") + if index % 20 == 19: + cpp_file.write("\n") + cpp_file.write("\n") + + header_file.write("}\n") + if options.flag: + header_file.write("#endif\n") + header_file.close() + + cpp_file.write("}\n") + if options.flag: + cpp_file.write("#endif\n") + cpp_file.close() + + +if __name__ == "__main__": + main() diff --git a/Source/web/tests/AssociatedURLLoaderTest.cpp b/Source/web/tests/AssociatedURLLoaderTest.cpp index 9ef5e3814..7795ef084 100644 --- a/Source/web/tests/AssociatedURLLoaderTest.cpp +++ b/Source/web/tests/AssociatedURLLoaderTest.cpp @@ -91,7 +91,8 @@ public: void SetUp() { m_webView = WebView::create(0); - m_webView->initializeMainFrame(&m_webFrameClient); + m_mainFrame = WebFrame::create(&m_webFrameClient); + m_webView->setMainFrame(m_mainFrame); std::string urlRoot = "http://www.test.com/"; WebCore::KURL url = RegisterMockedUrl(urlRoot, "iframes_test.html"); @@ -117,6 +118,7 @@ public: { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); m_webView->close(); + m_mainFrame->close(); } void serveRequests() @@ -274,6 +276,7 @@ protected: WTF::String m_frameFilePath; TestWebFrameClient m_webFrameClient; WebView* m_webView; + WebFrame* m_mainFrame; WebURLLoader* m_expectedLoader; WebURLResponse m_actualResponse; diff --git a/Source/web/tests/ChromeClientImplTest.cpp b/Source/web/tests/ChromeClientImplTest.cpp index 4d62f9ed5..3615a5bef 100644 --- a/Source/web/tests/ChromeClientImplTest.cpp +++ b/Source/web/tests/ChromeClientImplTest.cpp @@ -30,6 +30,7 @@ #include "config.h" +#include "WebFrame.h" #include "WebFrameClient.h" #include "WebInputEvent.h" #include "WebView.h" @@ -87,14 +88,16 @@ protected: virtual void SetUp() { m_webView = toWebViewImpl(WebView::create(&m_webViewClient)); - m_webView->initializeMainFrame(&m_webFrameClient); - m_chromeClientImpl = static_cast<ChromeClientImpl*>(&m_webView->page()->chrome().client()); + m_mainFrame = WebFrame::create(&m_webFrameClient); + m_webView->setMainFrame(m_mainFrame); + m_chromeClientImpl = toChromeClientImpl(m_webView->page()->chrome().client()); m_result = WebNavigationPolicyIgnore; } virtual void TearDown() { m_webView->close(); + m_mainFrame->close(); } WebNavigationPolicy getNavigationPolicyWithMouseEvent(int modifiers, WebMouseEvent::Button button, bool asPopup) @@ -120,6 +123,7 @@ protected: WebNavigationPolicy m_result; TestWebViewClient m_webViewClient; WebViewImpl* m_webView; + WebFrame* m_mainFrame; TestWebFrameClient m_webFrameClient; ChromeClientImpl* m_chromeClientImpl; }; diff --git a/Source/web/tests/RenderLayerBackingTest.cpp b/Source/web/tests/CompositedLayerMappingTest.cpp index f2e59f83b..5037d6366 100644 --- a/Source/web/tests/RenderLayerBackingTest.cpp +++ b/Source/web/tests/CompositedLayerMappingTest.cpp @@ -25,9 +25,8 @@ #include "config.h" -#include "core/rendering/RenderLayerBacking.h" +#include "core/rendering/CompositedLayerMapping.h" -#include <gtest/gtest.h> #include "FrameTestHelpers.h" #include "URLTestHelpers.h" #include "WebDocument.h" @@ -38,10 +37,12 @@ #include "WebViewClient.h" #include "WebViewImpl.h" #include "core/dom/Document.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "public/platform/Platform.h" #include "public/platform/WebUnitTestSupport.h" +#include <gtest/gtest.h> + using namespace WebKit; namespace WebCore { @@ -68,13 +69,14 @@ private: class MockWebFrameClient : public WebFrameClient { }; -class RenderLayerBackingTest : public testing::Test { +class CompositedLayerMappingTest : public testing::Test { public: - RenderLayerBackingTest() + CompositedLayerMappingTest() : m_baseURL("http://www.test.com/") { // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because the compositing // settings need to be set before the page is loaded. + m_mainFrame = WebFrame::create(&m_mockWebFrameClient); m_webViewImpl = toWebViewImpl(WebView::create(&m_mockWebViewClient)); m_webViewImpl->settings()->setForceCompositingMode(true); m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true); @@ -83,7 +85,7 @@ public: m_webViewImpl->settings()->setAcceleratedCompositingForScrollableFramesEnabled(true); m_webViewImpl->settings()->setCompositedScrollingForFramesEnabled(true); m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true); - m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient); + m_webViewImpl->setMainFrame(m_mainFrame); m_webViewImpl->resize(IntSize(320, 240)); } @@ -91,6 +93,7 @@ public: { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); m_webViewImpl->close(); + m_mainFrame->close(); } void navigateTo(const std::string& url) @@ -109,9 +112,10 @@ protected: MockWebFrameClient m_mockWebFrameClient; MockWebViewClient m_mockWebViewClient; WebViewImpl* m_webViewImpl; + WebFrame* m_mainFrame; }; -TEST_F(RenderLayerBackingTest, DISABLED_GraphicsLayerBackgroundColor) +TEST_F(CompositedLayerMappingTest, DISABLED_GraphicsLayerBackgroundColor) { registerMockedHttpURLLoad("layer_background_color.html"); navigateTo(m_baseURL + "layer_background_color.html"); @@ -121,12 +125,12 @@ TEST_F(RenderLayerBackingTest, DISABLED_GraphicsLayerBackgroundColor) Element* layerElement = document->getElementById("layer"); RenderLayerModelObject* renderer = toRenderLayerModelObject(layerElement->renderer()); EXPECT_EQ(renderer->style()->visitedDependentColor(CSSPropertyBackgroundColor), - renderer->layer()->backing()->graphicsLayer()->backgroundColor()); + renderer->layer()->compositedLayerMapping()->mainGraphicsLayer()->backgroundColor()); layerElement = document->getElementById("layer-solid-color"); renderer = toRenderLayerModelObject(layerElement->renderer()); - // RenderLayerBacking::graphicsLayer's background color is unset if SolidColorLayer is created. - EXPECT_EQ(Color(), renderer->layer()->backing()->graphicsLayer()->backgroundColor()); + // CompositedLayerMapping::graphicsLayer's background color is unset if SolidColorLayer is created. + EXPECT_EQ(Color(), renderer->layer()->compositedLayerMapping()->mainGraphicsLayer()->backgroundColor()); } } diff --git a/Source/web/tests/CustomEventTest.cpp b/Source/web/tests/CustomEventTest.cpp index 99310058d..808df33b2 100644 --- a/Source/web/tests/CustomEventTest.cpp +++ b/Source/web/tests/CustomEventTest.cpp @@ -59,7 +59,7 @@ public: return true; } - virtual void handleEvent(ScriptExecutionContext* context, Event* event) + virtual void handleEvent(ExecutionContext* context, Event* event) { EXPECT_EQ(event->type(), "blah"); @@ -100,8 +100,8 @@ TEST(CustomEventTest, InitWithSerializedScriptValue) const std::string path = "visible_iframe.html"; URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8(path.c_str())); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(baseURL + path); - WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); + FrameTestHelpers::WebViewHelper webViewHelper; + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.initializeAndLoad(baseURL + path)->mainFrame()); WebDOMEvent event = frame->frame()->document()->createEvent("CustomEvent", IGNORE_EXCEPTION); WebDOMCustomEvent customEvent = event.to<WebDOMCustomEvent>(); @@ -113,7 +113,6 @@ TEST(CustomEventTest, InitWithSerializedScriptValue) frame->frame()->document()->dispatchEvent(event); Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); - webView->close(); } } diff --git a/Source/web/tests/DragImageTest.cpp b/Source/web/tests/DragImageTest.cpp index 0f9d31da0..9e5151516 100644 --- a/Source/web/tests/DragImageTest.cpp +++ b/Source/web/tests/DragImageTest.cpp @@ -33,8 +33,8 @@ #include "core/platform/DragImage.h" #include "core/platform/graphics/Image.h" -#include "core/platform/graphics/IntSize.h" #include "core/platform/graphics/skia/NativeImageSkia.h" +#include "platform/geometry/IntSize.h" #include "third_party/skia/include/core/SkBitmap.h" #include "wtf/OwnPtr.h" #include "wtf/PassOwnPtr.h" @@ -83,11 +83,6 @@ public: { } - virtual unsigned decodedSize() const OVERRIDE - { - return 0u; - } - virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; diff --git a/Source/web/tests/FrameLoaderClientImplTest.cpp b/Source/web/tests/FrameLoaderClientImplTest.cpp index 85c433242..4a8fae3ca 100644 --- a/Source/web/tests/FrameLoaderClientImplTest.cpp +++ b/Source/web/tests/FrameLoaderClientImplTest.cpp @@ -69,13 +69,15 @@ public: void SetUp() { m_webView = WebView::create(0); - m_webView->initializeMainFrame(&m_webFrameClient); - m_frameLoaderClientImpl = static_cast<FrameLoaderClientImpl*>(toWebFrameImpl(m_webView->mainFrame())->frame()->loader()->client()); + m_mainFrame = WebFrame::create(&m_webFrameClient); + m_webView->setMainFrame(m_mainFrame); + m_frameLoaderClientImpl = toFrameLoaderClientImpl(toWebFrameImpl(m_webView->mainFrame())->frame()->loader()->client()); } void TearDown() { m_webView->close(); + m_mainFrame->close(); } void setUserAgentOverride(const WebString& userAgent) @@ -95,6 +97,7 @@ protected: TestWebFrameClient m_webFrameClient; FrameLoaderClientImpl* m_frameLoaderClientImpl; WebView* m_webView; + WebFrame* m_mainFrame; }; TEST_F(FrameLoaderClientImplTest, UserAgentOverride) diff --git a/Source/web/tests/FrameTestHelpers.cpp b/Source/web/tests/FrameTestHelpers.cpp index 97fa4a87c..90872adfb 100644 --- a/Source/web/tests/FrameTestHelpers.cpp +++ b/Source/web/tests/FrameTestHelpers.cpp @@ -33,11 +33,11 @@ #include "URLTestHelpers.h" #include "wtf/StdLibExtras.h" -#include "WebFrame.h" #include "WebFrameClient.h" +#include "WebFrameImpl.h" #include "WebSettings.h" -#include "WebView.h" #include "WebViewClient.h" +#include "WebViewImpl.h" #include "public/platform/Platform.h" #include "public/platform/WebString.h" #include "public/platform/WebThread.h" @@ -48,6 +48,30 @@ namespace WebKit { namespace FrameTestHelpers { +namespace { + +class QuitTask : public WebThread::Task { +public: + virtual void run() + { + Platform::current()->currentThread()->exitRunLoop(); + } +}; + +WebFrameClient* defaultWebFrameClient() +{ + DEFINE_STATIC_LOCAL(WebFrameClient, client, ()); + return &client; +} + +WebViewClient* defaultWebViewClient() +{ + DEFINE_STATIC_LOCAL(WebViewClient, client, ()); + return &client; +} + +} // namespace + void loadFrame(WebFrame* frame, const std::string& url) { WebURLRequest urlRequest; @@ -56,61 +80,66 @@ void loadFrame(WebFrame* frame, const std::string& url) frame->loadRequest(urlRequest); } -class TestWebFrameClient : public WebFrameClient { -}; - -static WebFrameClient* defaultWebFrameClient() +void runPendingTasks() { - DEFINE_STATIC_LOCAL(TestWebFrameClient, client, ()); - return &client; + Platform::current()->currentThread()->postTask(new QuitTask); + Platform::current()->currentThread()->enterRunLoop(); } -class TestWebViewClient : public WebViewClient { -}; +WebViewHelper::WebViewHelper() + : m_mainFrame(0) + , m_webView(0) +{ +} -static WebViewClient* defaultWebViewClient() +WebViewHelper::~WebViewHelper() { - DEFINE_STATIC_LOCAL(TestWebViewClient, client, ()); - return &client; + reset(); } -WebView* createWebView(bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient) +WebViewImpl* WebViewHelper::initialize(bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient, void (*updateSettingsFunc)(WebSettings*)) { + reset(); + if (!webFrameClient) webFrameClient = defaultWebFrameClient(); if (!webViewClient) webViewClient = defaultWebViewClient(); - WebView* webView = WebView::create(webViewClient); - webView->settings()->setJavaScriptEnabled(enableJavascript); - webView->settings()->setDeviceSupportsMouse(false); - webView->settings()->setForceCompositingMode(true); - webView->initializeMainFrame(webFrameClient); + m_webView = WebViewImpl::create(webViewClient); + m_webView->settings()->setJavaScriptEnabled(enableJavascript); + if (updateSettingsFunc) { + updateSettingsFunc(m_webView->settings()); + } else { + m_webView->settings()->setDeviceSupportsMouse(false); + m_webView->settings()->setForceCompositingMode(true); + } + + m_mainFrame = WebFrameImpl::create(webFrameClient); + m_webView->setMainFrame(m_mainFrame); - return webView; + return m_webView; } -WebView* createWebViewAndLoad(const std::string& url, bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient) +WebViewImpl* WebViewHelper::initializeAndLoad(const std::string& url, bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient, void (*updateSettingsFunc)(WebSettings*)) { - WebView* webView = createWebView(enableJavascript, webFrameClient, webViewClient); + initialize(enableJavascript, webFrameClient, webViewClient, updateSettingsFunc); - loadFrame(webView->mainFrame(), url); + loadFrame(webView()->mainFrame(), url); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - return webView; + return webViewImpl(); } -class QuitTask : public WebThread::Task { -public: - virtual void run() - { - Platform::current()->currentThread()->exitRunLoop(); - } -}; - -void runPendingTasks() +void WebViewHelper::reset() { - Platform::current()->currentThread()->postTask(new QuitTask); - Platform::current()->currentThread()->enterRunLoop(); + if (m_webView) { + m_webView->close(); + m_webView = 0; + } + if (m_mainFrame) { + m_mainFrame->close(); + m_mainFrame = 0; + } } } // namespace FrameTestHelpers diff --git a/Source/web/tests/FrameTestHelpers.h b/Source/web/tests/FrameTestHelpers.h index fa6200739..f981e4bae 100644 --- a/Source/web/tests/FrameTestHelpers.h +++ b/Source/web/tests/FrameTestHelpers.h @@ -31,24 +31,46 @@ #ifndef FrameTestHelpers_h #define FrameTestHelpers_h -#include <string> +#include "WebViewImpl.h" #include "wtf/PassOwnPtr.h" +#include <string> namespace WebKit { -class WebFrame; +class WebFrameImpl; class WebFrameClient; -class WebView; +class WebSettings; class WebViewClient; namespace FrameTestHelpers { void loadFrame(WebFrame*, const std::string& url); +void runPendingTasks(); -WebView* createWebView(bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0); -WebView* createWebViewAndLoad(const std::string& url, bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0); +// Convenience class for handling the lifetime of a WebView and its associated mainframe in tests. +class WebViewHelper { + WTF_MAKE_NONCOPYABLE(WebViewHelper); +public: + WebViewHelper(); + ~WebViewHelper(); -void runPendingTasks(); + // Creates and initializes the WebView. Implicitly calls reset() first. IF a + // WebFrameClient or a WebViewClient are passed in, they must outlive the + // WebViewHelper. + WebViewImpl* initialize(bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); + + // Same as initialize() but also performs the initial load of the url. + WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); + + void reset(); + + WebView* webView() const { return m_webView; } + WebViewImpl* webViewImpl() const { return m_webView; } + +private: + WebFrameImpl* m_mainFrame; + WebViewImpl* m_webView; +}; } // namespace FrameTestHelpers } // namespace WebKit diff --git a/Source/web/tests/ImageLayerChromiumTest.cpp b/Source/web/tests/ImageLayerChromiumTest.cpp index 116c4526c..b3c5a9b83 100644 --- a/Source/web/tests/ImageLayerChromiumTest.cpp +++ b/Source/web/tests/ImageLayerChromiumTest.cpp @@ -89,11 +89,6 @@ public: { } - virtual unsigned decodedSize() const OVERRIDE - { - return 0u; - } - virtual void draw(GraphicsContext*, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode) OVERRIDE { } diff --git a/Source/web/tests/LinkHighlightTest.cpp b/Source/web/tests/LinkHighlightTest.cpp index 92598146e..605b9dbc2 100644 --- a/Source/web/tests/LinkHighlightTest.cpp +++ b/Source/web/tests/LinkHighlightTest.cpp @@ -38,9 +38,9 @@ #include "WebViewImpl.h" #include "bindings/v8/ExceptionStatePlaceholder.h" #include "core/dom/Node.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/TouchDisambiguation.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/geometry/IntRect.h" #include "public/platform/Platform.h" #include "public/platform/WebContentLayer.h" #include "public/platform/WebFloatPoint.h" @@ -60,14 +60,15 @@ TEST(LinkHighlightTest, verifyWebViewImplIntegration) const std::string fileName("test_touch_link_highlight.html"); URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("test_touch_link_highlight.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true)); + FrameTestHelpers::WebViewHelper webViewHelper; + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true); int pageWidth = 640; int pageHeight = 480; webViewImpl->resize(WebSize(pageWidth, pageHeight)); webViewImpl->layout(); WebGestureEvent touchEvent; - touchEvent.type = WebInputEvent::GestureTapDown; + touchEvent.type = WebInputEvent::GestureShowPress; // The coordinates below are linked to absolute positions in the referenced .html file. touchEvent.x = 20; @@ -122,7 +123,6 @@ TEST(LinkHighlightTest, verifyWebViewImplIntegration) } ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); - webViewImpl->close(); Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); } @@ -165,7 +165,8 @@ TEST(LinkHighlightTest, resetDuringNodeRemoval) const std::string fileName("test_touch_link_highlight.html"); URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("test_touch_link_highlight.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true, 0, compositingWebViewClient())); + FrameTestHelpers::WebViewHelper webViewHelper; + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true, 0, compositingWebViewClient()); int pageWidth = 640; int pageHeight = 480; @@ -173,7 +174,7 @@ TEST(LinkHighlightTest, resetDuringNodeRemoval) webViewImpl->layout(); WebGestureEvent touchEvent; - touchEvent.type = WebInputEvent::GestureTapDown; + touchEvent.type = WebInputEvent::GestureShowPress; touchEvent.x = 20; touchEvent.y = 20; @@ -192,7 +193,6 @@ TEST(LinkHighlightTest, resetDuringNodeRemoval) webViewImpl->layout(); ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); - webViewImpl->close(); Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); } @@ -202,7 +202,8 @@ TEST(LinkHighlightTest, multipleHighlights) const std::string fileName("test_touch_link_highlight.html"); URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("test_touch_link_highlight.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true, 0, compositingWebViewClient())); + FrameTestHelpers::WebViewHelper webViewHelper; + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true, 0, compositingWebViewClient()); int pageWidth = 640; int pageHeight = 480; @@ -223,7 +224,6 @@ TEST(LinkHighlightTest, multipleHighlights) webViewImpl->enableTapHighlights(highlightNodes); EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); - webViewImpl->close(); Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); } diff --git a/Source/web/tests/ListenerLeakTest.cpp b/Source/web/tests/ListenerLeakTest.cpp index 3bd098dbf..655f3813e 100644 --- a/Source/web/tests/ListenerLeakTest.cpp +++ b/Source/web/tests/ListenerLeakTest.cpp @@ -87,26 +87,22 @@ int GetNumObjects(const char* constructor) class ListenerLeakTest : public testing::Test { public: - ListenerLeakTest() : m_webView(0) { } - void RunTest(const std::string& filename) { std::string baseURL("http://www.example.com/"); std::string fileName(filename); bool executeScript = true; URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8(fileName.c_str())); - m_webView = FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, executeScript); + webViewHelper.initializeAndLoad(baseURL + fileName, executeScript); } virtual void TearDown() OVERRIDE { - if (m_webView) - m_webView->close(); Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); } protected: - WebView* m_webView; + FrameTestHelpers::WebViewHelper webViewHelper; }; diff --git a/Source/web/tests/LocaleICUTest.cpp b/Source/web/tests/LocaleICUTest.cpp index aa5a3ff00..d875e737f 100644 --- a/Source/web/tests/LocaleICUTest.cpp +++ b/Source/web/tests/LocaleICUTest.cpp @@ -29,7 +29,7 @@ */ #include "config.h" -#include "core/platform/text/LocaleICU.h" +#include "platform/text/LocaleICU.h" #include <gtest/gtest.h> #include "wtf/PassOwnPtr.h" diff --git a/Source/web/tests/LocaleMacTest.cpp b/Source/web/tests/LocaleMacTest.cpp index c74c0fe81..0d1426cc2 100644 --- a/Source/web/tests/LocaleMacTest.cpp +++ b/Source/web/tests/LocaleMacTest.cpp @@ -24,10 +24,10 @@ */ #include "config.h" -#include "core/platform/text/mac/LocaleMac.h" +#include "platform/text/LocaleMac.h" #include <gtest/gtest.h> -#include "core/platform/DateComponents.h" +#include "platform/DateComponents.h" #include "wtf/DateMath.h" #include "wtf/MathExtras.h" #include "wtf/PassOwnPtr.h" diff --git a/Source/web/tests/LocaleWinTest.cpp b/Source/web/tests/LocaleWinTest.cpp index 966b072a3..c71e2df0b 100644 --- a/Source/web/tests/LocaleWinTest.cpp +++ b/Source/web/tests/LocaleWinTest.cpp @@ -29,10 +29,10 @@ */ #include "config.h" -#include "core/platform/text/win/LocaleWin.h" +#include "platform/text/LocaleWin.h" #include <gtest/gtest.h> -#include "core/platform/DateComponents.h" +#include "platform/DateComponents.h" #include "wtf/DateMath.h" #include "wtf/MathExtras.h" #include "wtf/PassOwnPtr.h" diff --git a/Source/web/tests/MemoryInfo.cpp b/Source/web/tests/MemoryInfo.cpp index d967c4eaa..bd1ed545c 100644 --- a/Source/web/tests/MemoryInfo.cpp +++ b/Source/web/tests/MemoryInfo.cpp @@ -30,7 +30,7 @@ #include "config.h" -#include "core/page/MemoryInfo.h" +#include "core/timing/MemoryInfo.h" #include <gtest/gtest.h> diff --git a/Source/web/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp b/Source/web/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp index 5ad9b41e0..7d60bcb99 100644 --- a/Source/web/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp +++ b/Source/web/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp @@ -28,7 +28,7 @@ #include "core/platform/graphics/Color.h" #include "core/platform/graphics/GraphicsContext.h" -#include "core/platform/graphics/IntRect.h" +#include "platform/geometry/IntRect.h" #include "skia/ext/platform_canvas.h" #include "public/platform/WebFloatRect.h" #include "public/platform/WebRect.h" diff --git a/Source/web/tests/OpenTypeVerticalDataTest.cpp b/Source/web/tests/OpenTypeVerticalDataTest.cpp index c70b69d53..61d04acdb 100644 --- a/Source/web/tests/OpenTypeVerticalDataTest.cpp +++ b/Source/web/tests/OpenTypeVerticalDataTest.cpp @@ -27,7 +27,7 @@ #if ENABLE(OPENTYPE_VERTICAL) #include <gtest/gtest.h> -#include "core/platform/SharedBuffer.h" +#include "platform/SharedBuffer.h" #include "core/platform/graphics/opentype/OpenTypeTypes.h" #include "wtf/RefPtr.h" diff --git a/Source/web/tests/PageSerializerTest.cpp b/Source/web/tests/PageSerializerTest.cpp index 222e2eda2..d52b563f5 100644 --- a/Source/web/tests/PageSerializerTest.cpp +++ b/Source/web/tests/PageSerializerTest.cpp @@ -82,7 +82,8 @@ protected: settings->setLoadsImagesAutomatically(true); settings->setJavaScriptEnabled(true); - m_webViewImpl->initializeMainFrame(&m_webFrameClient); + m_mainFrame = WebFrame::create(&m_webFrameClient); + m_webViewImpl->setMainFrame(m_mainFrame); } virtual void TearDown() @@ -90,6 +91,8 @@ protected: Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); m_webViewImpl->close(); m_webViewImpl = 0; + m_mainFrame->close(); + m_mainFrame = 0; } void setBaseUrl(const char* url) @@ -174,6 +177,7 @@ protected: private: TestWebFrameClient m_webFrameClient; + WebFrame* m_mainFrame; WebString m_folder; KURL m_baseUrl; Vector<SerializedResource> m_resources; diff --git a/Source/web/tests/PopupMenuTest.cpp b/Source/web/tests/PopupMenuTest.cpp index 4d95e5b3a..2d62988a2 100644 --- a/Source/web/tests/PopupMenuTest.cpp +++ b/Source/web/tests/PopupMenuTest.cpp @@ -32,6 +32,7 @@ #include "PopupContainer.h" #include "PopupMenuChromium.h" +#include "RuntimeEnabledFeatures.h" #include "URLTestHelpers.h" #include "WebDocument.h" #include "WebElement.h" @@ -48,21 +49,20 @@ #include "core/dom/Element.h" #include "core/html/HTMLSelectElement.h" #include "core/page/EventHandler.h" -#include "core/page/FrameView.h" -#include "RuntimeEnabledFeatures.h" -#include "core/platform/PlatformMouseEvent.h" +#include "core/frame/FrameView.h" #include "core/platform/PopupMenu.h" #include "core/platform/PopupMenuClient.h" #include "core/platform/chromium/KeyboardCodes.h" #include "core/platform/graphics/Color.h" -#include "v8.h" -#include <gtest/gtest.h> +#include "platform/PlatformMouseEvent.h" #include "public/platform/Platform.h" #include "public/platform/WebString.h" #include "public/platform/WebUnitTestSupport.h" #include "public/platform/WebURL.h" #include "public/platform/WebURLRequest.h" #include "public/platform/WebURLResponse.h" +#include "v8.h" +#include <gtest/gtest.h> using namespace WebCore; using namespace WebKit; diff --git a/Source/web/tests/PrerenderingTest.cpp b/Source/web/tests/PrerenderingTest.cpp index 39001c1ea..883f37428 100644 --- a/Source/web/tests/PrerenderingTest.cpp +++ b/Source/web/tests/PrerenderingTest.cpp @@ -177,49 +177,38 @@ private: class PrerenderingTest : public testing::Test { public: - PrerenderingTest() : m_webView(0) - { - } - ~PrerenderingTest() { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); - if (m_webView) - close(); } void initialize(const char* baseURL, const char* fileName) { - ASSERT(!m_webView); URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL), WebString::fromUTF8(fileName)); const bool RunJavascript = true; - m_webView = FrameTestHelpers::createWebView(RunJavascript); - m_webView->setPrerendererClient(&m_prerendererClient); + m_webViewHelper.initialize(RunJavascript); + m_webViewHelper.webView()->setPrerendererClient(&m_prerendererClient); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), std::string(baseURL) + fileName); + FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), std::string(baseURL) + fileName); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); } void navigateAway() { - FrameTestHelpers::loadFrame(m_webView->mainFrame(), "about:blank"); + FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:blank"); } void close() { - ASSERT(m_webView); - - m_webView->mainFrame()->collectGarbage(); - - m_webView->close(); - m_webView = 0; + m_webViewHelper.webView()->mainFrame()->collectGarbage(); + m_webViewHelper.reset(); WebCache::clear(); } WebElement console() { - WebElement console = m_webView->mainFrame()->document().getElementById("console"); + WebElement console = m_webViewHelper.webView()->mainFrame()->document().getElementById("console"); ASSERT(console.nodeName() == "UL"); return console; } @@ -245,7 +234,7 @@ public: void executeScript(const char* code) { - m_webView->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(code))); + m_webViewHelper.webView()->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(code))); } TestPrerenderingSupport* prerenderingSupport() @@ -262,7 +251,7 @@ private: TestPrerenderingSupport m_prerenderingSupport; TestPrerendererClient m_prerendererClient; - WebView* m_webView; + FrameTestHelpers::WebViewHelper m_webViewHelper; }; TEST_F(PrerenderingTest, SinglePrerender) diff --git a/Source/web/tests/ProgrammaticScrollTest.cpp b/Source/web/tests/ProgrammaticScrollTest.cpp index 19052dcc6..cbce87d9a 100644 --- a/Source/web/tests/ProgrammaticScrollTest.cpp +++ b/Source/web/tests/ProgrammaticScrollTest.cpp @@ -14,7 +14,7 @@ #include "WebView.h" #include "WebViewClient.h" #include "WebViewImpl.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/rendering/RenderView.h" #include "public/platform/Platform.h" #include "public/platform/WebUnitTestSupport.h" @@ -82,7 +82,8 @@ TEST_F(ProgrammaticScrollTest, UserScroll) registerMockedHttpURLLoad("short_scroll.html"); TestProgrammaticScrollClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "short_scroll.html", false, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "short_scroll.html", false, 0, &client); webView->resize(WebSize(1000, 1000)); webView->layout(); @@ -91,8 +92,6 @@ TEST_F(ProgrammaticScrollTest, UserScroll) // Non zero page scale and scroll. toWebViewImpl(webView)->applyScrollAndScale(WebSize(9, 13), 2.0f); EXPECT_FALSE(client.eventReceived()); - - webView->close(); } TEST_F(ProgrammaticScrollTest, ProgrammaticScroll) @@ -100,7 +99,8 @@ TEST_F(ProgrammaticScrollTest, ProgrammaticScroll) registerMockedHttpURLLoad("long_scroll.html"); TestProgrammaticScrollClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); webView->resize(WebSize(1000, 1000)); webView->layout(); @@ -126,8 +126,6 @@ TEST_F(ProgrammaticScrollTest, ProgrammaticScroll) frameImpl->executeScript(WebScriptSource("window.scrollBy(0, 0);")); EXPECT_FALSE(client.eventReceived()); client.reset(); - - webView->close(); } TEST_F(ProgrammaticScrollTest, UserScrollOnMainThread) @@ -135,7 +133,8 @@ TEST_F(ProgrammaticScrollTest, UserScrollOnMainThread) registerMockedHttpURLLoad("long_scroll.html"); TestProgrammaticScrollClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); webView->resize(WebSize(1000, 1000)); webView->layout(); @@ -156,8 +155,6 @@ TEST_F(ProgrammaticScrollTest, UserScrollOnMainThread) webView->handleInputEvent(gesture); FrameTestHelpers::runPendingTasks(); EXPECT_FALSE(client.eventReceived()); - - webView->close(); } TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) @@ -165,7 +162,8 @@ TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) registerMockedHttpURLLoad("long_scroll.html"); TestProgrammaticScrollClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); webView->resize(WebSize(1000, 1000)); webView->layout(); @@ -187,8 +185,6 @@ TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); EXPECT_TRUE(frameView->wasScrolledByUser()); EXPECT_FALSE(client.eventReceived()); - - webView->close(); } TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) @@ -196,7 +192,8 @@ TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) registerMockedHttpURLLoad("long_scroll.html"); TestProgrammaticScrollClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &client); webView->resize(WebSize(1000, 1000)); webView->layout(); @@ -221,8 +218,6 @@ TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); EXPECT_TRUE(frameView->wasScrolledByUser()); EXPECT_FALSE(client.eventReceived()); - - webView->close(); } } diff --git a/Source/web/tests/RegionTest.cpp b/Source/web/tests/RegionTest.cpp deleted file mode 100644 index 6356662ee..000000000 --- a/Source/web/tests/RegionTest.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "core/platform/graphics/Region.h" - -#include <gtest/gtest.h> - -using namespace WebCore; - -namespace { - -#define TEST_INSIDE_RECT(r, x, y, w, h) \ - EXPECT_TRUE(r.contains(IntPoint(x, y))); \ - EXPECT_TRUE(r.contains(IntPoint(x + w - 1, y))); \ - EXPECT_TRUE(r.contains(IntPoint(x, y + h - 1))); \ - EXPECT_TRUE(r.contains(IntPoint(x + w - 1, y + h - 1))); \ - EXPECT_TRUE(r.contains(IntPoint(x, y + h / 2))); \ - EXPECT_TRUE(r.contains(IntPoint(x + w - 1, y + h / 2))); \ - EXPECT_TRUE(r.contains(IntPoint(x + w / 2, y))); \ - EXPECT_TRUE(r.contains(IntPoint(x + w / 2, y + h - 1))); \ - EXPECT_TRUE(r.contains(IntPoint(x + w / 2, y + h / 2))); \ - -#define TEST_LEFT_OF_RECT(r, x, y, w, h) \ - EXPECT_FALSE(r.contains(IntPoint(x - 1, y))); \ - EXPECT_FALSE(r.contains(IntPoint(x - 1, y + h - 1))); \ - -#define TEST_RIGHT_OF_RECT(r, x, y, w, h) \ - EXPECT_FALSE(r.contains(IntPoint(x + w, y))); \ - EXPECT_FALSE(r.contains(IntPoint(x + w, y + h - 1))); \ - -#define TEST_TOP_OF_RECT(r, x, y, w, h) \ - EXPECT_FALSE(r.contains(IntPoint(x, y - 1))); \ - EXPECT_FALSE(r.contains(IntPoint(x + w - 1, y - 1))); \ - -#define TEST_BOTTOM_OF_RECT(r, x, y, w, h) \ - EXPECT_FALSE(r.contains(IntPoint(x, y + h))); \ - EXPECT_FALSE(r.contains(IntPoint(x + w - 1, y + h))); \ - -TEST(RegionTest, containsPoint) -{ - Region r; - - EXPECT_FALSE(r.contains(IntPoint(0, 0))); - - r.unite(IntRect(35, 35, 1, 1)); - TEST_INSIDE_RECT(r, 35, 35, 1, 1); - TEST_LEFT_OF_RECT(r, 35, 35, 1, 1); - TEST_RIGHT_OF_RECT(r, 35, 35, 1, 1); - TEST_TOP_OF_RECT(r, 35, 35, 1, 1); - TEST_BOTTOM_OF_RECT(r, 35, 35, 1, 1); - - r.unite(IntRect(30, 30, 10, 10)); - TEST_INSIDE_RECT(r, 30, 30, 10, 10); - TEST_LEFT_OF_RECT(r, 30, 30, 10, 10); - TEST_RIGHT_OF_RECT(r, 30, 30, 10, 10); - TEST_TOP_OF_RECT(r, 30, 30, 10, 10); - TEST_BOTTOM_OF_RECT(r, 30, 30, 10, 10); - - r.unite(IntRect(31, 40, 10, 10)); - EXPECT_FALSE(r.contains(IntPoint(30, 40))); - EXPECT_TRUE(r.contains(IntPoint(31, 40))); - EXPECT_FALSE(r.contains(IntPoint(40, 39))); - EXPECT_TRUE(r.contains(IntPoint(40, 40))); - - TEST_INSIDE_RECT(r, 30, 30, 10, 10); - TEST_LEFT_OF_RECT(r, 30, 30, 10, 10); - TEST_RIGHT_OF_RECT(r, 30, 30, 10, 10); - TEST_TOP_OF_RECT(r, 30, 30, 10, 10); - TEST_INSIDE_RECT(r, 31, 40, 10, 10); - TEST_LEFT_OF_RECT(r, 31, 40, 10, 10); - TEST_RIGHT_OF_RECT(r, 31, 40, 10, 10); - TEST_BOTTOM_OF_RECT(r, 31, 40, 10, 10); - - r.unite(IntRect(42, 40, 10, 10)); - - TEST_INSIDE_RECT(r, 42, 40, 10, 10); - TEST_LEFT_OF_RECT(r, 42, 40, 10, 10); - TEST_RIGHT_OF_RECT(r, 42, 40, 10, 10); - TEST_TOP_OF_RECT(r, 42, 40, 10, 10); - TEST_BOTTOM_OF_RECT(r, 42, 40, 10, 10); - - TEST_INSIDE_RECT(r, 30, 30, 10, 10); - TEST_LEFT_OF_RECT(r, 30, 30, 10, 10); - TEST_RIGHT_OF_RECT(r, 30, 30, 10, 10); - TEST_TOP_OF_RECT(r, 30, 30, 10, 10); - TEST_INSIDE_RECT(r, 31, 40, 10, 10); - TEST_LEFT_OF_RECT(r, 31, 40, 10, 10); - TEST_RIGHT_OF_RECT(r, 31, 40, 10, 10); - TEST_BOTTOM_OF_RECT(r, 31, 40, 10, 10); -} - -TEST(RegionTest, emptySpan) -{ - Region r; - r.unite(IntRect(5, 0, 10, 10)); - r.unite(IntRect(0, 5, 10, 10)); - r.subtract(IntRect(7, 7, 10, 0)); - - Vector<IntRect> rects = r.rects(); - for (size_t i = 0; i < rects.size(); ++i) - EXPECT_FALSE(rects[i].isEmpty()); -} - -#define TEST_NO_INTERSECT(a, b) \ -{ \ - Region ar = a; \ - Region br = b; \ - EXPECT_FALSE(ar.intersects(br)); \ - EXPECT_FALSE(br.intersects(ar)); \ -} - -#define TEST_INTERSECT(a, b) \ -{ \ - Region ar = a; \ - Region br = b; \ - EXPECT_TRUE(ar.intersects(br)); \ - EXPECT_TRUE(br.intersects(ar)); \ -} - -TEST(RegionTest, intersectsRegion) -{ - Region r; - - TEST_NO_INTERSECT(IntRect(), IntRect()); - TEST_NO_INTERSECT(IntRect(), IntRect(0, 0, 1, 1)); - TEST_NO_INTERSECT(IntRect(), IntRect(1, 1, 1, 1)); - - r.unite(IntRect(0, 0, 1, 1)); - TEST_NO_INTERSECT(r, IntRect()); - TEST_INTERSECT(r, IntRect(0, 0, 1, 1)); - TEST_INTERSECT(r, IntRect(0, 0, 2, 2)); - TEST_INTERSECT(r, IntRect(-1, 0, 2, 2)); - TEST_INTERSECT(r, IntRect(-1, -1, 2, 2)); - TEST_INTERSECT(r, IntRect(0, -1, 2, 2)); - TEST_INTERSECT(r, IntRect(-1, -1, 3, 3)); - - r.unite(IntRect(0, 0, 3, 3)); - r.unite(IntRect(10, 0, 3, 3)); - r.unite(IntRect(0, 10, 13, 3)); - TEST_NO_INTERSECT(r, IntRect()); - TEST_INTERSECT(r, IntRect(1, 1, 1, 1)); - TEST_INTERSECT(r, IntRect(0, 0, 2, 2)); - TEST_INTERSECT(r, IntRect(1, 0, 2, 2)); - TEST_INTERSECT(r, IntRect(1, 1, 2, 2)); - TEST_INTERSECT(r, IntRect(0, 1, 2, 2)); - TEST_INTERSECT(r, IntRect(0, 0, 3, 3)); - TEST_INTERSECT(r, IntRect(-1, -1, 2, 2)); - TEST_INTERSECT(r, IntRect(2, -1, 2, 2)); - TEST_INTERSECT(r, IntRect(2, 2, 2, 2)); - TEST_INTERSECT(r, IntRect(-1, 2, 2, 2)); - - TEST_INTERSECT(r, IntRect(11, 1, 1, 1)); - TEST_INTERSECT(r, IntRect(10, 0, 2, 2)); - TEST_INTERSECT(r, IntRect(11, 0, 2, 2)); - TEST_INTERSECT(r, IntRect(11, 1, 2, 2)); - TEST_INTERSECT(r, IntRect(10, 1, 2, 2)); - TEST_INTERSECT(r, IntRect(10, 0, 3, 3)); - TEST_INTERSECT(r, IntRect(9, -1, 2, 2)); - TEST_INTERSECT(r, IntRect(12, -1, 2, 2)); - TEST_INTERSECT(r, IntRect(12, 2, 2, 2)); - TEST_INTERSECT(r, IntRect(9, 2, 2, 2)); - - TEST_INTERSECT(r, IntRect(0, -1, 13, 5)); - TEST_INTERSECT(r, IntRect(1, -1, 11, 5)); - TEST_INTERSECT(r, IntRect(2, -1, 9, 5)); - TEST_INTERSECT(r, IntRect(2, -1, 8, 5)); - TEST_INTERSECT(r, IntRect(3, -1, 8, 5)); - TEST_NO_INTERSECT(r, IntRect(3, -1, 7, 5)); - - TEST_INTERSECT(r, IntRect(0, 1, 13, 1)); - TEST_INTERSECT(r, IntRect(1, 1, 11, 1)); - TEST_INTERSECT(r, IntRect(2, 1, 9, 1)); - TEST_INTERSECT(r, IntRect(2, 1, 8, 1)); - TEST_INTERSECT(r, IntRect(3, 1, 8, 1)); - TEST_NO_INTERSECT(r, IntRect(3, 1, 7, 1)); - - TEST_INTERSECT(r, IntRect(0, 0, 13, 13)); - TEST_INTERSECT(r, IntRect(0, 1, 13, 11)); - TEST_INTERSECT(r, IntRect(0, 2, 13, 9)); - TEST_INTERSECT(r, IntRect(0, 2, 13, 8)); - TEST_INTERSECT(r, IntRect(0, 3, 13, 8)); - TEST_NO_INTERSECT(r, IntRect(0, 3, 13, 7)); -} - -TEST(RegionTest, ReadPastFullSpanVectorInIntersectsTest) -{ - Region r; - - // This region has enough spans to fill its allocated Vector exactly. - r.unite(IntRect(400, 300, 1, 800)); - r.unite(IntRect(785, 585, 1, 1)); - r.unite(IntRect(787, 585, 1, 1)); - r.unite(IntRect(0, 587, 16, 162)); - r.unite(IntRect(26, 590, 300, 150)); - r.unite(IntRect(196, 750, 1, 1)); - r.unite(IntRect(0, 766, 1, 1)); - r.unite(IntRect(0, 782, 1, 1)); - r.unite(IntRect(745, 798, 1, 1)); - r.unite(IntRect(795, 882, 10, 585)); - r.unite(IntRect(100, 1499, 586, 1)); - r.unite(IntRect(100, 1500, 585, 784)); - // This query rect goes past the bottom of the Region, causing the - // test to reach the last span and try go past it. It should not read - // memory off the end of the span Vector. - TEST_NO_INTERSECT(r, IntRect(0, 2184, 1, 150)); -} - -#define TEST_NO_CONTAINS(a, b) \ -{ \ - Region ar = a; \ - Region br = b; \ - EXPECT_FALSE(ar.contains(br)); \ -} - -#define TEST_CONTAINS(a, b) \ -{ \ - Region ar = a; \ - Region br = b; \ - EXPECT_TRUE(ar.contains(br)); \ -} - -TEST(RegionTest, containsRegion) -{ - TEST_CONTAINS(IntRect(), IntRect()); - TEST_NO_CONTAINS(IntRect(), IntRect(0, 0, 1, 1)); - TEST_NO_CONTAINS(IntRect(), IntRect(1, 1, 1, 1)); - - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(11, 10, 1, 1)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(10, 11, 1, 1)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(9, 10, 1, 1)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(10, 9, 1, 1)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(9, 9, 2, 2)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(10, 9, 2, 2)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(9, 10, 2, 2)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(10, 10, 2, 2)); - TEST_NO_CONTAINS(IntRect(10, 10, 1, 1), IntRect(9, 9, 3, 3)); - - Region hLines; - for (int i = 10; i < 20; i += 2) - hLines.unite(IntRect(i, 10, 1, 10)); - - TEST_CONTAINS(IntRect(10, 10, 9, 10), hLines); - TEST_NO_CONTAINS(IntRect(10, 10, 9, 9), hLines); - TEST_NO_CONTAINS(IntRect(10, 11, 9, 9), hLines); - TEST_NO_CONTAINS(IntRect(10, 10, 8, 10), hLines); - TEST_NO_CONTAINS(IntRect(11, 10, 8, 10), hLines); - - Region vLines; - for (int i = 10; i < 20; i += 2) - vLines.unite(IntRect(10, i, 10, 1)); - - TEST_CONTAINS(IntRect(10, 10, 10, 9), vLines); - TEST_NO_CONTAINS(IntRect(10, 10, 9, 9), vLines); - TEST_NO_CONTAINS(IntRect(11, 10, 9, 9), vLines); - TEST_NO_CONTAINS(IntRect(10, 10, 10, 8), vLines); - TEST_NO_CONTAINS(IntRect(10, 11, 10, 8), vLines); - - Region grid; - for (int i = 10; i < 20; i += 2) - for (int j = 10; j < 20; j += 2) - grid.unite(IntRect(i, j, 1, 1)); - - TEST_CONTAINS(IntRect(10, 10, 9, 9), grid); - TEST_NO_CONTAINS(IntRect(10, 10, 9, 8), grid); - TEST_NO_CONTAINS(IntRect(10, 11, 9, 8), grid); - TEST_NO_CONTAINS(IntRect(10, 10, 8, 9), grid); - TEST_NO_CONTAINS(IntRect(11, 10, 8, 9), grid); - - TEST_CONTAINS(hLines, hLines); - TEST_CONTAINS(vLines, vLines); - TEST_NO_CONTAINS(vLines, hLines); - TEST_NO_CONTAINS(hLines, vLines); - TEST_CONTAINS(grid, grid); - TEST_CONTAINS(hLines, grid); - TEST_CONTAINS(vLines, grid); - TEST_NO_CONTAINS(grid, hLines); - TEST_NO_CONTAINS(grid, vLines); - - for (int i = 10; i < 20; i += 2) - TEST_CONTAINS(hLines, IntRect(i, 10, 1, 10)); - - for (int i = 10; i < 20; i += 2) - TEST_CONTAINS(vLines, IntRect(10, i, 10, 1)); - - for (int i = 10; i < 20; i += 2) - for (int j = 10; j < 20; j += 2) - TEST_CONTAINS(grid, IntRect(i, j, 1, 1)); - - Region container; - container.unite(IntRect(0, 0, 40, 20)); - container.unite(IntRect(0, 20, 41, 20)); - TEST_CONTAINS(container, IntRect(5, 5, 30, 30)); - - container = Region(); - container.unite(IntRect(0, 0, 10, 10)); - container.unite(IntRect(0, 30, 10, 10)); - container.unite(IntRect(30, 30, 10, 10)); - container.unite(IntRect(30, 0, 10, 10)); - TEST_NO_CONTAINS(container, IntRect(5, 5, 30, 30)); - - container = Region(); - container.unite(IntRect(0, 0, 10, 10)); - container.unite(IntRect(0, 30, 10, 10)); - container.unite(IntRect(30, 0, 10, 40)); - TEST_NO_CONTAINS(container, IntRect(5, 5, 30, 30)); - - container = Region(); - container.unite(IntRect(30, 0, 10, 10)); - container.unite(IntRect(30, 30, 10, 10)); - container.unite(IntRect(0, 0, 10, 40)); - TEST_NO_CONTAINS(container, IntRect(5, 5, 30, 30)); - - container = Region(); - container.unite(IntRect(0, 0, 10, 40)); - container.unite(IntRect(30, 0, 10, 40)); - TEST_NO_CONTAINS(container, IntRect(5, 5, 30, 30)); - - container = Region(); - container.unite(IntRect(0, 0, 40, 40)); - TEST_NO_CONTAINS(container, IntRect(10, -1, 20, 10)); - - container = Region(); - container.unite(IntRect(0, 0, 40, 40)); - TEST_NO_CONTAINS(container, IntRect(10, 31, 20, 10)); - - container = Region(); - container.unite(IntRect(0, 0, 40, 20)); - container.unite(IntRect(0, 20, 41, 20)); - TEST_NO_CONTAINS(container, IntRect(-1, 10, 10, 20)); - - container = Region(); - container.unite(IntRect(0, 0, 40, 20)); - container.unite(IntRect(0, 20, 41, 20)); - TEST_NO_CONTAINS(container, IntRect(31, 10, 10, 20)); - - container = Region(); - container.unite(IntRect(0, 0, 40, 40)); - container.subtract(IntRect(0, 20, 60, 0)); - TEST_NO_CONTAINS(container, IntRect(31, 10, 10, 20)); -} - -TEST(RegionTest, unite) -{ - Region r; - Region r2; - - // A rect uniting a contained rect does not change the region. - r2 = r = IntRect(0, 0, 50, 50); - r2.unite(IntRect(20, 20, 10, 10)); - EXPECT_EQ(r, r2); - - // A rect uniting a containing rect gives back the containing rect. - r = IntRect(0, 0, 50, 50); - r.unite(IntRect(0, 0, 100, 100)); - EXPECT_EQ(Region(IntRect(0, 0, 100, 100)), r); - - // A complex region uniting a contained rect does not change the region. - r = IntRect(0, 0, 50, 50); - r.unite(IntRect(100, 0, 50, 50)); - r2 = r; - r2.unite(IntRect(20, 20, 10, 10)); - EXPECT_EQ(r, r2); - - // A complex region uniting a containing rect gives back the containing rect. - r = IntRect(0, 0, 50, 50); - r.unite(IntRect(100, 0, 50, 50)); - r. unite(IntRect(0, 0, 500, 500)); - EXPECT_EQ(Region(IntRect(0, 0, 500, 500)), r); -} - -} // namespace diff --git a/Source/web/tests/RenderTableCellTest.cpp b/Source/web/tests/RenderTableCellTest.cpp index fa0bcc8f1..1c7fc1c0e 100644 --- a/Source/web/tests/RenderTableCellTest.cpp +++ b/Source/web/tests/RenderTableCellTest.cpp @@ -32,7 +32,7 @@ #include "WebFrameImpl.h" #include "WebView.h" #include "core/dom/Document.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include <gtest/gtest.h> @@ -43,23 +43,24 @@ namespace WebCore { namespace { class RenderTableCellDeathTest : public testing::Test { - // It's unfortunate that we have to get the whole browser stack to test one RenderObject - // but the code needs it. - static Frame* frame() +protected: + static void SetUpTestCase() { - static WebView* webView; - - if (webView) - return toWebFrameImpl(webView->mainFrame())->frame(); + // It's unfortunate that we have to get the whole browser stack to test one RenderObject + // but the code needs it. + s_webViewHelper = new FrameTestHelpers::WebViewHelper(); + s_webViewHelper->initializeAndLoad("about:blank"); + s_webViewHelper->webView()->setFocus(true); + } - webView = FrameTestHelpers::createWebViewAndLoad("about:blank"); - webView->setFocus(true); - return toWebFrameImpl(webView->mainFrame())->frame(); + static void TearDownTestCase() + { + delete s_webViewHelper; } static Document* document() { - return frame()->document(); + return toWebFrameImpl(s_webViewHelper->webView()->mainFrame())->frame()->document(); } virtual void SetUp() @@ -72,10 +73,14 @@ class RenderTableCellDeathTest : public testing::Test { m_cell->destroy(); } -protected: RenderTableCell* m_cell; + +private: + static FrameTestHelpers::WebViewHelper* s_webViewHelper; }; +FrameTestHelpers::WebViewHelper* RenderTableCellDeathTest::s_webViewHelper = 0; + TEST_F(RenderTableCellDeathTest, CanSetColumn) { static const unsigned columnIndex = 10; diff --git a/Source/web/tests/RenderTableRowTest.cpp b/Source/web/tests/RenderTableRowTest.cpp index 912e27a95..d0462339a 100644 --- a/Source/web/tests/RenderTableRowTest.cpp +++ b/Source/web/tests/RenderTableRowTest.cpp @@ -32,7 +32,7 @@ #include "WebFrameImpl.h" #include "WebView.h" #include "core/dom/Document.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include <gtest/gtest.h> @@ -43,23 +43,24 @@ namespace WebCore { namespace { class RenderTableRowDeathTest : public testing::Test { - // It's unfortunate that we have to get the whole browser stack to test one RenderObject - // but the code needs it. - static Frame* frame() +protected: + static void SetUpTestCase() { - static WebView* webView; - - if (webView) - return toWebFrameImpl(webView->mainFrame())->frame(); + // It's unfortunate that we have to get the whole browser stack to test one RenderObject + // but the code needs it. + s_webViewHelper = new FrameTestHelpers::WebViewHelper(); + s_webViewHelper->initializeAndLoad("about:blank"); + s_webViewHelper->webView()->setFocus(true); + } - webView = FrameTestHelpers::createWebViewAndLoad("about:blank"); - webView->setFocus(true); - return toWebFrameImpl(webView->mainFrame())->frame(); + static void TearDownTestCase() + { + delete s_webViewHelper; } static Document* document() { - return frame()->document(); + return toWebFrameImpl(s_webViewHelper->webView()->mainFrame())->frame()->document(); } virtual void SetUp() @@ -72,10 +73,14 @@ class RenderTableRowDeathTest : public testing::Test { m_row->destroy(); } -protected: RenderTableRow* m_row; + +private: + static FrameTestHelpers::WebViewHelper* s_webViewHelper; }; +FrameTestHelpers::WebViewHelper* RenderTableRowDeathTest::s_webViewHelper = 0; + TEST_F(RenderTableRowDeathTest, CanSetRow) { static const unsigned rowIndex = 10; diff --git a/Source/web/tests/RunAllTests.cpp b/Source/web/tests/RunAllTests.cpp index 399cd2e6a..d325c31cc 100644 --- a/Source/web/tests/RunAllTests.cpp +++ b/Source/web/tests/RunAllTests.cpp @@ -39,7 +39,7 @@ #include "public/platform/Platform.h" #include <content/test/webkit_unit_test_support.h> -#if defined(WEBKIT_DLL_UNITTEST) +#if defined(BLINK_DLL_UNITTEST) #include "WebUnitTests.h" #endif @@ -51,7 +51,7 @@ // and run inside webkit.dll. int main(int argc, char** argv) { -#if defined(WEBKIT_DLL_UNITTEST) +#if defined(BLINK_DLL_UNITTEST) WebKit::InitTestSuite(argc, argv); content::SetUpTestEnvironmentForWebKitUnitTests(); int result = WebKit::RunAllUnitTests(); diff --git a/Source/web/tests/ScrollAnimatorNoneTest.cpp b/Source/web/tests/ScrollAnimatorNoneTest.cpp index ec2ee07dc..87a16ecc9 100644 --- a/Source/web/tests/ScrollAnimatorNoneTest.cpp +++ b/Source/web/tests/ScrollAnimatorNoneTest.cpp @@ -31,12 +31,11 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include "core/platform/Logging.h" +#include "platform/Logging.h" #include "core/platform/ScrollAnimator.h" #include "core/platform/ScrollableArea.h" -#include "core/platform/graphics/FloatPoint.h" -#include "core/platform/graphics/IntRect.h" -#include "core/tests/TreeTestHelpers.h" +#include "platform/geometry/FloatPoint.h" +#include "platform/geometry/IntRect.h" using namespace std; using namespace WebCore; diff --git a/Source/web/tests/ScrollingCoordinatorChromiumTest.cpp b/Source/web/tests/ScrollingCoordinatorChromiumTest.cpp index 0a5e9b8a3..dc845c34b 100644 --- a/Source/web/tests/ScrollingCoordinatorChromiumTest.cpp +++ b/Source/web/tests/ScrollingCoordinatorChromiumTest.cpp @@ -35,7 +35,7 @@ #include "WebViewClient.h" #include "WebViewImpl.h" #include "core/platform/graphics/GraphicsLayer.h" -#include "core/rendering/RenderLayerBacking.h" +#include "core/rendering/CompositedLayerMapping.h" #include "core/rendering/RenderLayerCompositor.h" #include "core/rendering/RenderView.h" #include "public/platform/Platform.h" @@ -76,6 +76,7 @@ public: { // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because the compositing // settings need to be set before the page is loaded. + m_mainFrame = WebFrame::create(&m_mockWebFrameClient); m_webViewImpl = toWebViewImpl(WebView::create(&m_mockWebViewClient)); m_webViewImpl->settings()->setJavaScriptEnabled(true); m_webViewImpl->settings()->setForceCompositingMode(true); @@ -85,7 +86,7 @@ public: m_webViewImpl->settings()->setAcceleratedCompositingForScrollableFramesEnabled(true); m_webViewImpl->settings()->setCompositedScrollingForFramesEnabled(true); m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true); - m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient); + m_webViewImpl->setMainFrame(m_mainFrame); m_webViewImpl->resize(IntSize(320, 240)); } @@ -93,6 +94,7 @@ public: { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); m_webViewImpl->close(); + m_mainFrame->close(); } void navigateTo(const std::string& url) @@ -121,6 +123,7 @@ protected: MockWebFrameClient m_mockWebFrameClient; FakeWebViewClient m_mockWebViewClient; WebViewImpl* m_webViewImpl; + WebFrame* m_mainFrame; }; TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) @@ -150,10 +153,10 @@ static WebLayer* webLayerFromElement(Element* element) RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); if (!layer) return 0; - RenderLayerBacking* backing = layer->backing(); - if (!backing) + CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping(); + if (!compositedLayerMapping) return 0; - GraphicsLayer* graphicsLayer = backing->graphicsLayer(); + GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); if (!graphicsLayer) return 0; return graphicsLayer->platformLayer(); @@ -291,22 +294,22 @@ TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling) ASSERT_TRUE(layer->usesCompositedScrolling()); ASSERT_TRUE(layer->isComposited()); - RenderLayerBacking* layerBacking = layer->backing(); - ASSERT_TRUE(layerBacking->hasScrollingLayer()); - ASSERT(layerBacking->scrollingContentsLayer()); + CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping(); + ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); + ASSERT(compositedLayerMapping->scrollingContentsLayer()); - GraphicsLayer* graphicsLayer = layerBacking->scrollingContentsLayer(); + GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLayer(); ASSERT_EQ(layer->scrollableArea(), graphicsLayer->scrollableArea()); - WebLayer* webScrollLayer = layerBacking->scrollingContentsLayer()->platformLayer(); + WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()->platformLayer(); ASSERT_TRUE(webScrollLayer->scrollable()); #if OS(ANDROID) // Now verify we've attached impl-side scrollbars onto the scrollbar layers - ASSERT_TRUE(layerBacking->layerForHorizontalScrollbar()); - ASSERT_TRUE(layerBacking->layerForHorizontalScrollbar()->hasContentsLayer()); - ASSERT_TRUE(layerBacking->layerForVerticalScrollbar()); - ASSERT_TRUE(layerBacking->layerForVerticalScrollbar()->hasContentsLayer()); + ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()); + ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()->hasContentsLayer()); + ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); + ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); #endif } diff --git a/Source/web/tests/TransparencyWinTest.cpp b/Source/web/tests/TransparencyWinTest.cpp index 9c5392548..a21cf9960 100644 --- a/Source/web/tests/TransparencyWinTest.cpp +++ b/Source/web/tests/TransparencyWinTest.cpp @@ -33,7 +33,7 @@ #include "core/platform/graphics/GraphicsContext.h" #include "core/platform/graphics/ImageBuffer.h" -#include "core/platform/graphics/transforms/AffineTransform.h" +#include "platform/transforms/AffineTransform.h" #include "skia/ext/platform_canvas.h" #include <windows.h> diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp index cc19d0517..0e734c0f4 100644 --- a/Source/web/tests/WebFrameTest.cpp +++ b/Source/web/tests/WebFrameTest.cpp @@ -32,6 +32,7 @@ #include "WebFrame.h" +#include <gmock/gmock.h> #include <gtest/gtest.h> #include "FrameTestHelpers.h" #include "RuntimeEnabledFeatures.h" @@ -62,21 +63,21 @@ #include "core/dom/Range.h" #include "core/editing/Editor.h" #include "core/editing/FrameSelection.h" -#include "core/editing/SpellCheckRequester.h" +#include "core/editing/SpellChecker.h" #include "core/editing/VisiblePosition.h" #include "core/html/HTMLFormElement.h" #include "core/loader/FrameLoadRequest.h" #include "core/page/EventHandler.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" #include "core/page/Settings.h" #include "core/platform/ScrollbarTheme.h" -#include "core/platform/graphics/FloatRect.h" -#include "core/platform/network/ResourceError.h" #include "core/rendering/HitTestResult.h" #include "core/rendering/RenderLayerCompositor.h" #include "core/rendering/RenderView.h" #include "core/rendering/TextAutosizer.h" +#include "platform/geometry/FloatRect.h" +#include "platform/network/ResourceError.h" #include "v8.h" #include "public/platform/Platform.h" #include "public/platform/WebFloatRect.h" @@ -85,6 +86,7 @@ #include "public/platform/WebURLResponse.h" #include "wtf/dtoa/utils.h" #include "wtf/Forward.h" +#include <map> using namespace WebKit; using WebCore::Document; @@ -134,22 +136,15 @@ private: }; class WebFrameTest : public testing::Test { -public: +protected: WebFrameTest() : m_baseURL("http://www.test.com/") , m_chromeURL("chrome://") - , m_webView(0) { } virtual ~WebFrameTest() { - if (m_webView) - m_webView->close(); - } - - virtual void TearDown() - { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); } @@ -163,29 +158,27 @@ public: URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chromeURL.c_str()), WebString::fromUTF8(fileName.c_str())); } - void createCompositingWebView() + static void configueCompositingWebView(WebSettings* settings) { - m_fakeCompositingWebViewClient = adoptPtr(new FakeCompositingWebViewClient()); - m_webView = WebView::create(m_fakeCompositingWebViewClient.get()); - m_webView->settings()->setJavaScriptEnabled(true); - m_webView->settings()->setForceCompositingMode(true); - m_webView->settings()->setAcceleratedCompositingEnabled(true); - m_webView->settings()->setAcceleratedCompositingForFixedPositionEnabled(true); - m_webView->settings()->setAcceleratedCompositingForOverflowScrollEnabled(true); - m_webView->settings()->setAcceleratedCompositingForScrollableFramesEnabled(true); - m_webView->settings()->setCompositedScrollingForFramesEnabled(true); - m_webView->settings()->setFixedPositionCreatesStackingContext(true); - m_webView->initializeMainFrame(&m_fakeCompositingWebViewClient->m_fakeWebFrameClient); + settings->setForceCompositingMode(true); + settings->setAcceleratedCompositingEnabled(true); + settings->setAcceleratedCompositingForFixedPositionEnabled(true); + settings->setAcceleratedCompositingForOverflowScrollEnabled(true); + settings->setAcceleratedCompositingForScrollableFramesEnabled(true); + settings->setCompositedScrollingForFramesEnabled(true); + settings->setFixedPositionCreatesStackingContext(true); } -protected: - WebViewImpl* webViewImpl() const { return toWebViewImpl(m_webView); } + void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers::WebViewHelper* webViewHelper) + { + webViewHelper->initializeAndLoad(url, true); + webViewHelper->webView()->settings()->setDefaultFontSize(12); + webViewHelper->webView()->enableFixedLayoutMode(false); + webViewHelper->webView()->resize(WebSize(640, 480)); + } std::string m_baseURL; std::string m_chromeURL; - OwnPtr<FakeCompositingWebViewClient> m_fakeCompositingWebViewClient; - - WebView* m_webView; }; class UseMockScrollbarSettings { @@ -211,10 +204,11 @@ TEST_F(WebFrameTest, ContentText) registerMockedHttpURLLoad("invisible_iframe.html"); registerMockedHttpURLLoad("zero_sized_iframe.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html"); // Now retrieve the frames text and test it only includes visible elements. - std::string content = std::string(m_webView->mainFrame()->contentAsText(1024).utf8().data()); + std::string content = webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8(); EXPECT_NE(std::string::npos, content.find(" visible paragraph")); EXPECT_NE(std::string::npos, content.find(" visible iframe")); EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); @@ -229,27 +223,24 @@ TEST_F(WebFrameTest, FrameForEnteredContext) registerMockedHttpURLLoad("invisible_iframe.html"); registerMockedHttpURLLoad("zero_sized_iframe.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html", true); v8::HandleScope scope(v8::Isolate::GetCurrent()); - EXPECT_EQ(m_webView->mainFrame(), - WebFrame::frameForContext( - m_webView->mainFrame()->mainWorldScriptContext())); - EXPECT_EQ(m_webView->mainFrame()->firstChild(), - WebFrame::frameForContext( - m_webView->mainFrame()->firstChild()->mainWorldScriptContext())); + EXPECT_EQ(webViewHelper.webView()->mainFrame(), WebFrame::frameForContext(webViewHelper.webView()->mainFrame()->mainWorldScriptContext())); + EXPECT_EQ(webViewHelper.webView()->mainFrame()->firstChild(), WebFrame::frameForContext(webViewHelper.webView()->mainFrame()->firstChild()->mainWorldScriptContext())); } TEST_F(WebFrameTest, FormWithNullFrame) { registerMockedHttpURLLoad("form.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "form.html"); WebVector<WebFormElement> forms; - m_webView->mainFrame()->document().forms(forms); - m_webView->close(); - m_webView = 0; + webViewHelper.webView()->mainFrame()->document().forms(forms); + webViewHelper.reset(); EXPECT_EQ(forms.size(), 1U); @@ -262,16 +253,17 @@ TEST_F(WebFrameTest, ChromePageJavascript) registerMockedChromeURLLoad("history.html"); // Pass true to enable JavaScript. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.html", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); // Try to run JS against the chrome-style URL. - FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Clobbered'))"); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Clobbered'))"); // Required to see any updates in contentAsText. - m_webView->layout(); + webViewHelper.webView()->layout(); // Now retrieve the frame's text and ensure it was modified by running javascript. - std::string content = std::string(m_webView->mainFrame()->contentAsText(1024).utf8().data()); + std::string content = webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8(); EXPECT_NE(std::string::npos, content.find("Clobbered")); } @@ -280,44 +272,308 @@ TEST_F(WebFrameTest, ChromePageNoJavascript) registerMockedChromeURLLoad("history.html"); /// Pass true to enable JavaScript. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.html", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); // Try to run JS against the chrome-style URL after prohibiting it. WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Clobbered'))"); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Clobbered'))"); // Required to see any updates in contentAsText. - m_webView->layout(); + webViewHelper.webView()->layout(); // Now retrieve the frame's text and ensure it wasn't modified by running javascript. - std::string content = std::string(m_webView->mainFrame()->contentAsText(1024).utf8().data()); + std::string content = webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8(); EXPECT_EQ(std::string::npos, content.find("Clobbered")); } +class CSSCallbackWebFrameClient : public WebFrameClient { +public: + CSSCallbackWebFrameClient() : m_updateCount(0) { } + virtual void didMatchCSS(WebFrame*, const WebVector<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) OVERRIDE; + + std::map<WebFrame*, std::set<std::string> > m_matchedSelectors; + int m_updateCount; +}; + +void CSSCallbackWebFrameClient::didMatchCSS(WebFrame* frame, const WebVector<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) +{ + ++m_updateCount; + std::set<std::string>& frameSelectors = m_matchedSelectors[frame]; + for (size_t i = 0; i < newlyMatchingSelectors.size(); ++i) { + std::string selector = newlyMatchingSelectors[i].utf8(); + EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; + frameSelectors.insert(selector); + } + for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { + std::string selector = stoppedMatchingSelectors[i].utf8(); + EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; + frameSelectors.erase(selector); + } +} + +class WebFrameCSSCallbackTest : public testing::Test { +protected: + WebFrameCSSCallbackTest() + { + + m_frame = m_helper.initializeAndLoad("about:blank", true, &m_client)->mainFrame(); + } + + ~WebFrameCSSCallbackTest() + { + EXPECT_EQ(1U, m_client.m_matchedSelectors.size()); + } + + WebDocument doc() const + { + return m_frame->document(); + } + + int updateCount() const + { + return m_client.m_updateCount; + } + + const std::set<std::string>& matchedSelectors() + { + return m_client.m_matchedSelectors[m_frame]; + } + + void loadHTML(const WebData& html) + { + m_frame->loadHTMLString(html, toKURL("about:blank")); + runPendingTasks(); + } + + void executeScript(const WebString& code) + { + m_frame->executeScript(WebScriptSource(code)); + runPendingTasks(); + } + + CSSCallbackWebFrameClient m_client; + FrameTestHelpers::WebViewHelper m_helper; + WebFrame* m_frame; +}; + +TEST_F(WebFrameCSSCallbackTest, AuthorStyleSheet) +{ + loadHTML( + "<style>" + // This stylesheet checks that the internal property and value can't be + // set by a stylesheet, only WebDocument::watchCSSSelectors(). + "div.initial_on { -internal-callback: none; }" + "div.initial_off { -internal-callback: -internal-presence; }" + "</style>" + "<div class=\"initial_on\"></div>" + "<div class=\"initial_off\"></div>"); + + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("div.initial_on")); + m_frame->document().watchCSSSelectors(WebVector<WebString>(selectors)); + runPendingTasks(); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("div.initial_on")); + + // Check that adding a watched selector calls back for already-present nodes. + selectors.push_back(WebString::fromUTF8("div.initial_off")); + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + runPendingTasks(); + EXPECT_EQ(2, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("div.initial_off", "div.initial_on")); + + // Check that we can turn off callbacks for certain selectors. + doc().watchCSSSelectors(WebVector<WebString>()); + runPendingTasks(); + EXPECT_EQ(3, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); +} + +TEST_F(WebFrameCSSCallbackTest, SharedRenderStyle) +{ + // Check that adding an element calls back when it matches an existing rule. + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("span")); + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + + executeScript( + "i1 = document.createElement('span');" + "i1.id = 'first_span';" + "document.body.appendChild(i1)"); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); + + // Adding a second element that shares a RenderStyle shouldn't call back. + // We use <span>s to avoid default style rules that can set + // RenderStyle::unique(). + executeScript( + "i2 = document.createElement('span');" + "i2.id = 'second_span';" + "i1 = document.getElementById('first_span');" + "i1.parentNode.insertBefore(i2, i1.nextSibling);"); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); + + // Removing the first element shouldn't call back. + executeScript( + "i1 = document.getElementById('first_span');" + "i1.parentNode.removeChild(i1);"); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); + + // But removing the second element *should* call back. + executeScript( + "i2 = document.getElementById('second_span');" + "i2.parentNode.removeChild(i2);"); + EXPECT_EQ(2, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); +} + +TEST_F(WebFrameCSSCallbackTest, CatchesAttributeChange) +{ + loadHTML("<span></span>"); + + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("span[attr=\"value\"]")); + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + runPendingTasks(); + + EXPECT_EQ(0, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); + + executeScript( + "document.querySelector('span').setAttribute('attr', 'value');"); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span[attr=\"value\"]")); +} + +TEST_F(WebFrameCSSCallbackTest, DisplayNone) +{ + loadHTML("<div style='display:none'><span></span></div>"); + + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("span")); + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + runPendingTasks(); + + EXPECT_EQ(0, updateCount()) << "Don't match elements in display:none trees."; + + executeScript( + "d = document.querySelector('div');" + "d.style.display = 'block';"); + EXPECT_EQ(1, updateCount()) << "Match elements when they become displayed."; + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); + + executeScript( + "d = document.querySelector('div');" + "d.style.display = 'none';"); + EXPECT_EQ(2, updateCount()) << "Unmatch elements when they become undisplayed."; + EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); + + executeScript( + "s = document.querySelector('span');" + "s.style.display = 'none';"); + EXPECT_EQ(2, updateCount()) << "No effect from no-display'ing a span that's already undisplayed."; + + executeScript( + "d = document.querySelector('div');" + "d.style.display = 'block';"); + EXPECT_EQ(2, updateCount()) << "No effect from displaying a div whose span is display:none."; + + executeScript( + "s = document.querySelector('span');" + "s.style.display = 'inline';"); + EXPECT_EQ(3, updateCount()) << "Now the span is visible and produces a callback."; + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); + + executeScript( + "s = document.querySelector('span');" + "s.style.display = 'none';"); + EXPECT_EQ(4, updateCount()) << "Undisplaying the span directly should produce another callback."; + EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); +} + +TEST_F(WebFrameCSSCallbackTest, Reparenting) +{ + loadHTML( + "<div id='d1'><span></span></div>" + "<div id='d2'></div>"); + + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("span")); + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + runPendingTasks(); + + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); + + executeScript( + "s = document.querySelector('span');" + "d2 = document.getElementById('d2');" + "d2.appendChild(s);"); + EXPECT_EQ(1, updateCount()) << "Just moving an element that continues to match shouldn't send a spurious callback."; + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); +} + +TEST_F(WebFrameCSSCallbackTest, MultiSelector) +{ + loadHTML("<span></span>"); + + // Check that selector lists match as the whole list, not as each element + // independently. + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("span")); + selectors.push_back(WebString::fromUTF8("span,p")); + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + + runPendingTasks(); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span", "span, p")); +} + +TEST_F(WebFrameCSSCallbackTest, InvalidSelector) +{ + loadHTML("<p><span></span></p>"); + + // Build a list with one valid selector and one invalid. + std::vector<WebString> selectors; + selectors.push_back(WebString::fromUTF8("span")); + selectors.push_back(WebString::fromUTF8("[")); // Invalid. + selectors.push_back(WebString::fromUTF8("p span")); // Not compound. + doc().watchCSSSelectors(WebVector<WebString>(selectors)); + + runPendingTasks(); + EXPECT_EQ(1, updateCount()); + EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")) + << "An invalid selector shouldn't prevent other selectors from matching."; +} + TEST_F(WebFrameTest, DispatchMessageEventWithOriginCheck) { registerMockedHttpURLLoad("postmessage_test.html"); // Pass true to enable JavaScript. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "postmessage_test.html", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "postmessage_test.html", true); // Send a message with the correct origin. WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))); - WebDOMEvent event = m_webView->mainFrame()->document().createEvent("MessageEvent"); + WebDOMEvent event = webViewHelper.webView()->mainFrame()->document().createEvent("MessageEvent"); WebDOMMessageEvent message = event.to<WebDOMMessageEvent>(); WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); message.initMessageEvent("message", false, false, data, "http://origin.com", 0, ""); - m_webView->mainFrame()->dispatchMessageEventWithOriginCheck(correctOrigin, message); + webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(correctOrigin, message); // Send another message with incorrect origin. WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create(toKURL(m_chromeURL))); - m_webView->mainFrame()->dispatchMessageEventWithOriginCheck(incorrectOrigin, message); + webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(incorrectOrigin, message); // Required to see any updates in contentAsText. - m_webView->layout(); + webViewHelper.webView()->layout(); // Verify that only the first addition is in the body of the page. - std::string content = std::string(m_webView->mainFrame()->contentAsText(1024).utf8().data()); + std::string content = webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8(); EXPECT_NE(std::string::npos, content.find("Message 1.")); EXPECT_EQ(std::string::npos, content.find("Message 2.")); } @@ -339,20 +595,21 @@ TEST_F(WebFrameTest, FrameViewNeedsLayoutOnFixedLayoutResize) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - webViewImpl()->mainFrameImpl()->frameView()->setFixedLayoutSize(WebCore::IntSize(100, 100)); - EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); + webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFixedLayoutSize(WebCore::IntSize(100, 100)); + EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); - int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCount(); - webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebCore::IntRect(0, 0, 641, 481)); - EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layoutCount()); + int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutCount(); + webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebCore::IntRect(0, 0, 641, 481)); + EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutCount()); - webViewImpl()->layout(); + webViewHelper.webViewImpl()->layout(); } TEST_F(WebFrameTest, ChangeInFixedLayoutTriggersTextAutosizingRecalculate) @@ -365,15 +622,16 @@ TEST_F(WebFrameTest, ChangeInFixedLayoutTriggersTextAutosizingRecalculate) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); - WebCore::Document* document = webViewImpl()->page()->mainFrame()->document(); + WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame()->document(); document->settings()->setTextAutosizingEnabled(true); EXPECT_TRUE(document->settings()->textAutosizingEnabled()); - webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); - webViewImpl()->layout(); + webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webViewImpl()->layout(); WebCore::RenderObject* renderer = document->renderer(); bool multiplierSetAtLeastOnce = false; @@ -387,11 +645,11 @@ TEST_F(WebFrameTest, ChangeInFixedLayoutTriggersTextAutosizingRecalculate) } EXPECT_TRUE(multiplierSetAtLeastOnce); - WebCore::ViewportArguments arguments = document->viewportArguments(); + WebCore::ViewportDescription description = document->viewportDescription(); // Choose a width that's not going match the viewport width of the loaded document. - arguments.minWidth = WebCore::Length(100, WebCore::Fixed); - arguments.maxWidth = WebCore::Length(100, WebCore::Fixed); - webViewImpl()->updatePageDefinedPageScaleConstraints(arguments); + description.minWidth = WebCore::Length(100, WebCore::Fixed); + description.maxWidth = WebCore::Length(100, WebCore::Fixed); + webViewHelper.webViewImpl()->updatePageDefinedPageScaleConstraints(description); bool multiplierCheckedAtLeastOnce = false; renderer = document->renderer(); @@ -415,15 +673,16 @@ TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) int fixedLayoutWidth = viewportWidth / 2; int fixedLayoutHeight = viewportHeight / 2; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight)); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - EXPECT_EQ(fixedLayoutWidth, m_webView->fixedLayoutSize().width); - EXPECT_EQ(fixedLayoutHeight, m_webView->fixedLayoutSize().height); + EXPECT_EQ(fixedLayoutWidth, webViewHelper.webView()->fixedLayoutSize().width); + EXPECT_EQ(fixedLayoutHeight, webViewHelper.webView()->fixedLayoutSize().height); } TEST_F(WebFrameTest, FixedLayoutSizePreventsResizeFromChangingPageScale) @@ -436,17 +695,18 @@ TEST_F(WebFrameTest, FixedLayoutSizePreventsResizeFromChangingPageScale) int fixedLayoutWidth = viewportWidth / 2; int fixedLayoutHeight = viewportHeight / 2; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight)); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); - float pageScaleFactor = m_webView->pageScaleFactor(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); + float pageScaleFactor = webViewHelper.webView()->pageScaleFactor(); - m_webView->resize(WebSize(viewportWidth * 2, viewportHeight * 2)); + webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight * 2)); - EXPECT_EQ(pageScaleFactor, m_webView->pageScaleFactor()); + EXPECT_EQ(pageScaleFactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, FixedLayoutSizePreventsLayoutFromChangingPageScale) @@ -459,18 +719,19 @@ TEST_F(WebFrameTest, FixedLayoutSizePreventsLayoutFromChangingPageScale) int fixedLayoutWidth = viewportWidth * 2; int fixedLayoutHeight = viewportHeight * 2; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight)); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); - float pageScaleFactor = m_webView->pageScaleFactor(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); + float pageScaleFactor = webViewHelper.webView()->pageScaleFactor(); - m_webView->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight)); - m_webView->layout(); + webViewHelper.webView()->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight)); + webViewHelper.webView()->layout(); - EXPECT_EQ(pageScaleFactor, m_webView->pageScaleFactor()); + EXPECT_EQ(pageScaleFactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, PreferredSizeAndContentSizeReportedCorrectlyWithZeroHeightFixedLayout) @@ -487,18 +748,19 @@ TEST_F(WebFrameTest, PreferredSizeAndContentSizeReportedCorrectlyWithZeroHeightF FixedLayoutTestWebViewClient client; client.m_screenInfo.deviceScaleFactor = 1; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "200-by-300.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(windowWidth, windowHeight)); - m_webView->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(windowWidth, windowHeight)); + webViewHelper.webView()->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - EXPECT_EQ(divWidth, m_webView->mainFrame()->contentsSize().width); - EXPECT_EQ(divHeight, m_webView->mainFrame()->contentsSize().height); + EXPECT_EQ(divWidth, webViewHelper.webView()->mainFrame()->contentsSize().width); + EXPECT_EQ(divHeight, webViewHelper.webView()->mainFrame()->contentsSize().height); - EXPECT_EQ(divWidth, m_webView->contentsPreferredMinimumSize().width); - EXPECT_EQ(divHeight, m_webView->contentsPreferredMinimumSize().height); + EXPECT_EQ(divWidth, webViewHelper.webView()->contentsPreferredMinimumSize().width); + EXPECT_EQ(divHeight, webViewHelper.webView()->contentsPreferredMinimumSize().height); } TEST_F(WebFrameTest, DisablingFixedLayoutSizeSetsCorrectLayoutSize) @@ -510,22 +772,23 @@ TEST_F(WebFrameTest, DisablingFixedLayoutSizeSetsCorrectLayoutSize) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client); - m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setUseWideViewport(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - - m_webView->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight)); - EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); - m_webView->layout(); - EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); - - m_webView->setFixedLayoutSize(WebSize(0, 0)); - EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); - m_webView->layout(); - EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client); + webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(true); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + + webViewHelper.webView()->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight)); + EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); + webViewHelper.webView()->layout(); + EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + + webViewHelper.webView()->setFixedLayoutSize(WebSize(0, 0)); + EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); + webViewHelper.webView()->layout(); + EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); } TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag) @@ -538,23 +801,24 @@ TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag) FixedLayoutTestWebViewClient client; client.m_screenInfo.deviceScaleFactor = 2; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client); - m_webView->settings()->setViewportEnabled(true); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - EXPECT_EQ(2, m_webView->deviceScaleFactor()); + EXPECT_EQ(2, webViewHelper.webView()->deviceScaleFactor()); // Device scale factor should be independent of page scale. - m_webView->setPageScaleFactorLimits(1, 2); - m_webView->setPageScaleFactorPreservingScrollOffset(0.5); - m_webView->layout(); - EXPECT_EQ(1, m_webView->pageScaleFactor()); + webViewHelper.webView()->setPageScaleFactorLimits(1, 2); + webViewHelper.webView()->setPageScaleFactorPreservingScrollOffset(0.5); + webViewHelper.webView()->layout(); + EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); // Force the layout to happen before leaving the test. - m_webView->mainFrame()->contentAsText(1024).utf8(); + webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8(); } TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumScale) @@ -570,30 +834,31 @@ TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumScale) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); int defaultFixedLayoutWidth = 980; float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWidth; - EXPECT_EQ(minimumPageScaleFactor, m_webView->pageScaleFactor()); - EXPECT_EQ(minimumPageScaleFactor, m_webView->minimumPageScaleFactor()); + EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); + EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleFactor()); // Assume the user has pinch zoomed to page scale factor 2. float userPinchPageScaleFactor = 2; - m_webView->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor); - m_webView->layout(); + webViewHelper.webView()->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor); + webViewHelper.webView()->layout(); // Make sure we don't reset to initial scale if the page continues to load. bool isNewNavigation; - webViewImpl()->didCommitLoad(&isNewNavigation, false); - webViewImpl()->didChangeContentsSize(); - EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); + webViewHelper.webViewImpl()->didCommitLoad(&isNewNavigation, false); + webViewHelper.webViewImpl()->didChangeContentsSize(); + EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); // Make sure we don't reset to initial scale if the viewport size changes. - m_webView->resize(WebSize(viewportWidth, viewportHeight + 100)); - EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight + 100)); + EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, WideDocumentInitializeAtMinimumScale) @@ -609,30 +874,31 @@ TEST_F(WebFrameTest, WideDocumentInitializeAtMinimumScale) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "wide_document.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "wide_document.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); int wideDocumentWidth = 1500; float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; - EXPECT_EQ(minimumPageScaleFactor, m_webView->pageScaleFactor()); - EXPECT_EQ(minimumPageScaleFactor, m_webView->minimumPageScaleFactor()); + EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); + EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleFactor()); // Assume the user has pinch zoomed to page scale factor 2. float userPinchPageScaleFactor = 2; - m_webView->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor); - m_webView->layout(); + webViewHelper.webView()->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor); + webViewHelper.webView()->layout(); // Make sure we don't reset to initial scale if the page continues to load. bool isNewNavigation; - webViewImpl()->didCommitLoad(&isNewNavigation, false); - webViewImpl()->didChangeContentsSize(); - EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); + webViewHelper.webViewImpl()->didCommitLoad(&isNewNavigation, false); + webViewHelper.webViewImpl()->didChangeContentsSize(); + EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); // Make sure we don't reset to initial scale if the viewport size changes. - m_webView->resize(WebSize(viewportWidth, viewportHeight + 100)); - EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight + 100)); + EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) @@ -644,15 +910,16 @@ TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-auto-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setLoadWithOverviewMode(false); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); // The page must be displayed at 100% zoom. - EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); + EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, SetLoadWithOverviewModeToFalseAndNoWideViewport) @@ -664,16 +931,17 @@ TEST_F(WebFrameTest, SetLoadWithOverviewModeToFalseAndNoWideViewport) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "large-div.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setLoadWithOverviewMode(false); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(false); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); // The page must be displayed at 100% zoom, despite that it hosts a wide div element. - EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); + EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidth) @@ -685,16 +953,17 @@ TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidth) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-auto-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(false); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); // The page sets viewport width to 3000, but with UseWideViewport == false is must be ignored. - EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); - EXPECT_EQ(viewportHeight, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); + EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); } TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccountsScale) @@ -706,17 +975,18 @@ TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccountsScale) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(false); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); // The page sets viewport width to 3000, but with UseWideViewport == false is must be ignored. // While the initial scale specified by the page must be accounted. - EXPECT_EQ(viewportWidth / 2, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); - EXPECT_EQ(viewportHeight / 2, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); + EXPECT_EQ(viewportWidth / 2, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + EXPECT_EQ(viewportHeight / 2, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); } TEST_F(WebFrameTest, WideViewportSetsTo980WithoutViewportTag) @@ -728,15 +998,16 @@ TEST_F(WebFrameTest, WideViewportSetsTo980WithoutViewportTag) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); - EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); + EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); } TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta) @@ -748,14 +1019,15 @@ TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-height-1000.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(false); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-height-1000.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(false); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); } TEST_F(WebFrameTest, WideViewportSetsTo980WithAutoWidth) @@ -767,15 +1039,16 @@ TEST_F(WebFrameTest, WideViewportSetsTo980WithAutoWidth) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-2x-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); - EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); + EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().height()); } TEST_F(WebFrameTest, PageViewportInitialScaleOverridesLoadWithOverviewMode) @@ -787,14 +1060,15 @@ TEST_F(WebFrameTest, PageViewportInitialScaleOverridesLoadWithOverviewMode) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setLoadWithOverviewMode(false); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); // The page must be displayed at 200% zoom, as specified in its viewport meta tag. - EXPECT_EQ(2.0f, m_webView->pageScaleFactor()); + EXPECT_EQ(2.0f, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, setInitialPageScaleFactorPermanently) @@ -807,26 +1081,27 @@ TEST_F(WebFrameTest, setInitialPageScaleFactorPermanently) client.m_screenInfo.deviceScaleFactor = 1; float enforcedPageScaleFactor = 2.0f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setLoadWithOverviewMode(false); - m_webView->setInitialPageScaleOverride(enforcedPageScaleFactor); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); + webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->layout(); - EXPECT_EQ(enforcedPageScaleFactor, m_webView->pageScaleFactor()); + EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); int viewportWidth = 640; int viewportHeight = 480; - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - EXPECT_EQ(enforcedPageScaleFactor, m_webView->pageScaleFactor()); + EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); - m_webView->setInitialPageScaleOverride(-1); - m_webView->layout(); - EXPECT_EQ(1.0, m_webView->pageScaleFactor()); + webViewHelper.webView()->setInitialPageScaleOverride(-1); + webViewHelper.webView()->layout(); + EXPECT_EQ(1.0, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesLoadWithOverviewMode) @@ -839,14 +1114,15 @@ TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesLoadWithOverviewMod int viewportHeight = 480; float enforcedPageScalePactor = 0.5f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-auto-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setLoadWithOverviewMode(false); - m_webView->setInitialPageScaleOverride(enforcedPageScalePactor); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); + webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScalePactor); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - EXPECT_EQ(enforcedPageScalePactor, m_webView->pageScaleFactor()); + EXPECT_EQ(enforcedPageScalePactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesPageViewportInitialScale) @@ -859,13 +1135,14 @@ TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesPageViewportInitial int viewportHeight = 480; float enforcedPageScalePactor = 0.5f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->setInitialPageScaleOverride(enforcedPageScalePactor); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScalePactor); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - EXPECT_EQ(enforcedPageScalePactor, m_webView->pageScaleFactor()); + EXPECT_EQ(enforcedPageScalePactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, WideViewportInitialScaleDoesNotExpandFixedLayoutWidth) @@ -877,16 +1154,44 @@ TEST_F(WebFrameTest, WideViewportInitialScaleDoesNotExpandFixedLayoutWidth) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-device-0.5x-initial-scale.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - m_webView->settings()->setUseWideViewport(true); - m_webView->settings()->setViewportMetaLayoutSizeQuirk(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-device-0.5x-initial-scale.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - WebViewImpl* webViewImpl = toWebViewImpl(m_webView); - EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLayoutSize().width()); + EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->fixedLayoutSize().width()); +} + +TEST_F(WebFrameTest, WideViewportAndWideContentWithInitialScale) +{ + registerMockedHttpURLLoad("wide_document_width_viewport.html"); + + FixedLayoutTestWebViewClient client; + client.m_screenInfo.deviceScaleFactor = 1; + int viewportWidth = 600; + int viewportHeight = 800; + + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:blank", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "wide_document_width_viewport.html"); + Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + + int wideDocumentWidth = 800; + float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; + EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); + EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleFactor()); } TEST_F(WebFrameTest, ZeroValuesQuirk) @@ -898,23 +1203,23 @@ TEST_F(WebFrameTest, ZeroValuesQuirk) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebView(true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setViewportMetaZeroValuesQuirk(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "viewport-zero-values.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-zero-values.html"); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - WebViewImpl* webViewImpl = toWebViewImpl(m_webView); - EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLayoutSize().width()); - EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); + EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->fixedLayoutSize().width()); + EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); - m_webView->settings()->setUseWideViewport(true); - m_webView->layout(); - EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLayoutSize().width()); - EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->layout(); + EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->fixedLayoutSize().width()); + EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, OverflowHiddenDisablesScrolling) @@ -926,12 +1231,13 @@ TEST_F(WebFrameTest, OverflowHiddenDisablesScrolling) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebView(true, 0, &client); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "body-overflow-hidden.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, 0, &client); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html"); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); EXPECT_FALSE(view->userInputScrollable(WebCore::VerticalScrollbar)); } @@ -944,13 +1250,14 @@ TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebView(true, 0, &client); - m_webView->settings()->setIgnoreMainFrameOverflowHiddenQuirk(true); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "body-overflow-hidden.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, 0, &client); + webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(true); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html"); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); EXPECT_TRUE(view->userInputScrollable(WebCore::VerticalScrollbar)); } @@ -964,23 +1271,23 @@ TEST_F(WebFrameTest, NonZeroValuesNoQuirk) int viewportHeight = 480; float expectedPageScaleFactor = 0.5f; - m_webView = FrameTestHelpers::createWebView(true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setViewportMetaZeroValuesQuirk(true); - m_webView->settings()->setWideViewportQuirkEnabled(true); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "viewport-nonzero-values.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-nonzero-values.html"); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - WebViewImpl* webViewImpl = toWebViewImpl(m_webView); - EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewImpl->mainFrameImpl()->frameView()->fixedLayoutSize().width()); - EXPECT_EQ(expectedPageScaleFactor, m_webView->pageScaleFactor()); + EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->fixedLayoutSize().width()); + EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); - m_webView->settings()->setUseWideViewport(true); - m_webView->layout(); - EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewImpl->mainFrameImpl()->frameView()->fixedLayoutSize().width()); - EXPECT_EQ(expectedPageScaleFactor, m_webView->pageScaleFactor()); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->layout(); + EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->fixedLayoutSize().width()); + EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, ScaleFactorShouldNotOscillate) @@ -992,11 +1299,12 @@ TEST_F(WebFrameTest, ScaleFactorShouldNotOscillate) int viewportWidth = 800; int viewportHeight = 1057; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "scale_oscillate.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "scale_oscillate.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); } TEST_F(WebFrameTest, setPageScaleFactorDoesNotLayout) @@ -1009,16 +1317,17 @@ TEST_F(WebFrameTest, setPageScaleFactorDoesNotLayout) int viewportWidth = 64; int viewportHeight = 48; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); - - int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCount(); - webViewImpl()->setPageScaleFactor(3, WebPoint()); - EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); - EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layoutCount()); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); + + int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutCount(); + webViewHelper.webViewImpl()->setPageScaleFactor(3, WebPoint()); + EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); + EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutCount()); } TEST_F(WebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) @@ -1032,16 +1341,17 @@ TEST_F(WebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCount(); - webViewImpl()->setPageScaleFactor(30, WebPoint()); - EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); - EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layoutCount()); + int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutCount(); + webViewHelper.webViewImpl()->setPageScaleFactor(30, WebPoint()); + EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); + EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutCount()); } @@ -1050,12 +1360,13 @@ TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) registerMockedHttpURLLoad("fixed_layout.html"); float pageScaleFactor = 3; - m_webView = FrameTestHelpers::createWebViewAndLoad("about:html", true, 0, 0); - m_webView->setPageScaleFactor(pageScaleFactor, WebPoint()); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:html", true, 0, 0); + webViewHelper.webView()->setPageScaleFactor(pageScaleFactor, WebPoint()); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "fixed_layout.html"); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html"); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); EXPECT_EQ(pageScaleFactor, view->visibleContentScaleFactor()); } @@ -1068,17 +1379,18 @@ TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); - - m_webView->setPageScaleFactor(3, WebPoint()); - webViewImpl()->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState(); - m_webView->setPageScaleFactor(1, WebPoint()); - webViewImpl()->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState(); - EXPECT_EQ(3, m_webView->pageScaleFactor()); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); + + webViewHelper.webView()->setPageScaleFactor(3, WebPoint()); + webViewHelper.webViewImpl()->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState(); + webViewHelper.webView()->setPageScaleFactor(1, WebPoint()); + webViewHelper.webViewImpl()->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState(); + EXPECT_EQ(3, webViewHelper.webView()->pageScaleFactor()); } TEST_F(WebFrameTest, pageScaleFactorShrinksViewport) @@ -1091,17 +1403,18 @@ TEST_F(WebFrameTest, pageScaleFactorShrinksViewport) int viewportWidth = 64; int viewportHeight = 48; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "large-div.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()->isOverlayScrollbar() ? 0 : 15); int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollbar()->isOverlayScrollbar() ? 0 : 15); - m_webView->setPageScaleFactor(2, WebPoint()); + webViewHelper.webView()->setPageScaleFactor(2, WebPoint()); WebCore::IntSize unscaledSize = view->unscaledVisibleContentSize(WebCore::ScrollableArea::IncludeScrollbars); EXPECT_EQ(viewportWidth, unscaledSize.width()); @@ -1125,16 +1438,17 @@ TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - m_webView->setPageScaleFactor(2, WebPoint()); + webViewHelper.webView()->setPageScaleFactor(2, WebPoint()); - EXPECT_EQ(980, webViewImpl()->page()->mainFrame()->contentRenderer()->unscaledDocumentRect().width()); - EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); + EXPECT_EQ(980, webViewHelper.webViewImpl()->page()->mainFrame()->contentRenderer()->unscaledDocumentRect().width()); + EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width()); } TEST_F(WebFrameTest, targetDensityDpiHigh) @@ -1154,21 +1468,20 @@ TEST_F(WebFrameTest, targetDensityDpiHigh) float deviceDpi = deviceScaleFactor * 160.0f; client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-target-densitydpi-high.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-high.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); // We need to account for the fact that logical pixels are unconditionally multiplied by deviceScaleFactor to produce // physical pixels. float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; - EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, m_webView->fixedLayoutSize().width, 1.0f); - EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, m_webView->fixedLayoutSize().height, 1.0f); - EXPECT_NEAR(1.0f / densityDpiScaleRatio, m_webView->pageScaleFactor(), 0.01f); - - m_webView->close(); - m_webView = 0; + EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webView()->fixedLayoutSize().width, 1.0f); + EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView()->fixedLayoutSize().height, 1.0f); + EXPECT_NEAR(1.0f / densityDpiScaleRatio, webViewHelper.webView()->pageScaleFactor(), 0.01f); } } @@ -1186,21 +1499,100 @@ TEST_F(WebFrameTest, targetDensityDpiDevice) for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-target-densitydpi-device.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-device.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + + EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->fixedLayoutSize().width, 1.0f); + EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->fixedLayoutSize().height, 1.0f); + EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->pageScaleFactor(), 0.01f); + } +} + +TEST_F(WebFrameTest, targetDensityDpiDeviceAndFixedWidth) +{ + UseMockScrollbarSettings mockScrollbarSettings; + registerMockedHttpURLLoad("viewport-target-densitydpi-device-and-fixed-width.html"); - EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, m_webView->fixedLayoutSize().width, 1.0f); - EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, m_webView->fixedLayoutSize().height, 1.0f); - EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, m_webView->pageScaleFactor(), 0.01f); + float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; - m_webView->close(); - m_webView = 0; + FixedLayoutTestWebViewClient client; + int viewportWidth = 640; + int viewportHeight = 480; + + for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { + client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; + + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-device-and-fixed-width.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(true); + webViewHelper.webView()->settings()->setUseWideViewport(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + + EXPECT_NEAR(viewportWidth, webViewHelper.webView()->fixedLayoutSize().width, 1.0f); + EXPECT_NEAR(viewportHeight, webViewHelper.webView()->fixedLayoutSize().height, 1.0f); + EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); } } +TEST_F(WebFrameTest, NoWideViewportAndScaleLessThanOne) +{ + UseMockScrollbarSettings mockScrollbarSettings; + registerMockedHttpURLLoad("viewport-initial-scale-less-than-1.html"); + + FixedLayoutTestWebViewClient client; + client.m_screenInfo.deviceScaleFactor = 1.33f; + int viewportWidth = 640; + int viewportHeight = 480; + + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-than-1.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); + + EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->fixedLayoutSize().width, 1.0f); + EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->fixedLayoutSize().height, 1.0f); + EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->pageScaleFactor(), 0.01f); +} + +TEST_F(WebFrameTest, NoWideViewportAndScaleLessThanOneWithDeviceWidth) +{ + UseMockScrollbarSettings mockScrollbarSettings; + registerMockedHttpURLLoad("viewport-initial-scale-less-than-1-device-width.html"); + + FixedLayoutTestWebViewClient client; + client.m_screenInfo.deviceScaleFactor = 1.33f; + int viewportWidth = 640; + int viewportHeight = 480; + + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-than-1-device-width.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(true); + webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); + webViewHelper.webView()->settings()->setUseWideViewport(false); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); + + const float pageZoom = 0.25f; + EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom, webViewHelper.webView()->fixedLayoutSize().width, 1.0f); + EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoom, webViewHelper.webView()->fixedLayoutSize().height, 1.0f); + EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webView()->pageScaleFactor(), 0.01f); +} + class WebFrameResizeTest : public WebFrameTest { protected: @@ -1220,60 +1612,61 @@ protected: const float aspectRatio = static_cast<float>(viewportSize.width) / viewportSize.height; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + url, true); - m_webView->settings()->setViewportEnabled(true); - m_webView->enableFixedLayoutMode(true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + url, true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->enableFixedLayoutMode(true); // Origin scrollOffsets preserved under resize. { - webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height)); - webViewImpl()->setPageScaleFactor(initialPageScaleFactor, WebPoint()); - ASSERT_EQ(viewportSize, webViewImpl()->size()); - ASSERT_EQ(initialPageScaleFactor, webViewImpl()->pageScaleFactor()); - webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.width)); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height)); + webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFactor, WebPoint()); + ASSERT_EQ(viewportSize, webViewHelper.webViewImpl()->size()); + ASSERT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFactor()); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.width)); float expectedPageScaleFactor = initialPageScaleFactor * (shouldScaleRelativeToViewportWidth ? 1 / aspectRatio : 1); - EXPECT_NEAR(expectedPageScaleFactor, webViewImpl()->pageScaleFactor(), 0.05f); - EXPECT_EQ(WebSize(), webViewImpl()->mainFrame()->scrollOffset()); + EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFactor(), 0.05f); + EXPECT_EQ(WebSize(), webViewHelper.webViewImpl()->mainFrame()->scrollOffset()); } // Resizing just the height should not affect pageScaleFactor or scrollOffset. { - webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height)); - webViewImpl()->setPageScaleFactor(initialPageScaleFactor, WebPoint(scrollOffset.width, scrollOffset.height)); - webViewImpl()->layout(); - const WebSize expectedScrollOffset = webViewImpl()->mainFrame()->scrollOffset(); - webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); - EXPECT_EQ(initialPageScaleFactor, webViewImpl()->pageScaleFactor()); - EXPECT_EQ(expectedScrollOffset, webViewImpl()->mainFrame()->scrollOffset()); - webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); - EXPECT_EQ(initialPageScaleFactor, webViewImpl()->pageScaleFactor()); - EXPECT_EQ(expectedScrollOffset, webViewImpl()->mainFrame()->scrollOffset()); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height)); + webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFactor, WebPoint(scrollOffset.width, scrollOffset.height)); + webViewHelper.webViewImpl()->layout(); + const WebSize expectedScrollOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOffset(); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); + EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFactor()); + EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOffset()); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); + EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFactor()); + EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOffset()); } // Generic resize preserves scrollOffset relative to anchor node located // the top center of the screen. { - webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.width)); - float pageScaleFactor = webViewImpl()->pageScaleFactor(); - webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height)); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.width)); + float pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor(); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.height)); float expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelativeToViewportWidth ? aspectRatio : 1); - EXPECT_NEAR(expectedPageScaleFactor, webViewImpl()->pageScaleFactor(), 0.05f); - webViewImpl()->mainFrame()->setScrollOffset(scrollOffset); + EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFactor(), 0.05f); + webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffset); WebCore::IntPoint anchorPoint = WebCore::IntPoint(scrollOffset) + WebCore::IntPoint(viewportSize.width / 2, 0); - RefPtr<WebCore::Node> anchorNode = webViewImpl()->mainFrameImpl()->frame()->eventHandler()->hitTestResultAtPoint(anchorPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent).innerNode(); + RefPtr<WebCore::Node> anchorNode = webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler()->hitTestResultAtPoint(anchorPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent).innerNode(); ASSERT(anchorNode); - pageScaleFactor = webViewImpl()->pageScaleFactor(); + pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor(); const WebCore::FloatSize preResizeRelativeOffset = computeRelativeOffset(anchorPoint, anchorNode->boundingBox()); - webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.width)); - WebCore::IntPoint newAnchorPoint = WebCore::IntPoint(webViewImpl()->mainFrame()->scrollOffset()) + WebCore::IntPoint(viewportSize.height / 2, 0); + webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.width)); + WebCore::IntPoint newAnchorPoint = WebCore::IntPoint(webViewHelper.webViewImpl()->mainFrame()->scrollOffset()) + WebCore::IntPoint(viewportSize.height / 2, 0); const WebCore::FloatSize postResizeRelativeOffset = computeRelativeOffset(newAnchorPoint, anchorNode->boundingBox()); EXPECT_NEAR(preResizeRelativeOffset.width(), postResizeRelativeOffset.width(), 0.15f); expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelativeToViewportWidth ? 1 / aspectRatio : 1); - EXPECT_NEAR(expectedPageScaleFactor, webViewImpl()->pageScaleFactor(), 0.05f); + EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFactor(), 0.05f); } } }; @@ -1328,15 +1721,16 @@ TEST_F(WebFrameTest, pageScaleFactorScalesPaintClip) int viewportWidth = 50; int viewportHeight = 50; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "large-div.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); // Set <1 page scale so that the clip rect should be larger than // the viewport size as passed into resize(). - m_webView->setPageScaleFactor(0.5, WebPoint()); + webViewHelper.webView()->setPageScaleFactor(0.5, WebPoint()); SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200); @@ -1349,7 +1743,7 @@ TEST_F(WebFrameTest, pageScaleFactorScalesPaintClip) EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); WebCore::IntRect paintRect(0, 0, 200, 200); view->paint(&context, paintRect); @@ -1369,17 +1763,18 @@ TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize().width() - view->visibleContentRect().width()); EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize().height() - view->visibleContentRect().height()); - m_webView->setPageScaleFactor(10, WebPoint()); + webViewHelper.webView()->setPageScaleFactor(10, WebPoint()); EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize().width() - view->visibleContentRect().width()); EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize().height() - view->visibleContentRect().height()); @@ -1396,25 +1791,26 @@ TEST_F(WebFrameTest, CanOverrideScaleLimits) int viewportWidth = 640; int viewportHeight = 480; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for_you.html", true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "no_scale_for_you.html", true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); - EXPECT_EQ(2.0f, m_webView->minimumPageScaleFactor()); - EXPECT_EQ(2.0f, m_webView->maximumPageScaleFactor()); + EXPECT_EQ(2.0f, webViewHelper.webView()->minimumPageScaleFactor()); + EXPECT_EQ(2.0f, webViewHelper.webView()->maximumPageScaleFactor()); - m_webView->setIgnoreViewportTagScaleLimits(true); - m_webView->layout(); + webViewHelper.webView()->setIgnoreViewportTagScaleLimits(true); + webViewHelper.webView()->layout(); - EXPECT_EQ(1.0f, m_webView->minimumPageScaleFactor()); - EXPECT_EQ(5.0f, m_webView->maximumPageScaleFactor()); + EXPECT_EQ(1.0f, webViewHelper.webView()->minimumPageScaleFactor()); + EXPECT_EQ(5.0f, webViewHelper.webView()->maximumPageScaleFactor()); - m_webView->setIgnoreViewportTagScaleLimits(false); - m_webView->layout(); + webViewHelper.webView()->setIgnoreViewportTagScaleLimits(false); + webViewHelper.webView()->layout(); - EXPECT_EQ(2.0f, m_webView->minimumPageScaleFactor()); - EXPECT_EQ(2.0f, m_webView->maximumPageScaleFactor()); + EXPECT_EQ(2.0f, webViewHelper.webView()->minimumPageScaleFactor()); + EXPECT_EQ(2.0f, webViewHelper.webView()->maximumPageScaleFactor()); } TEST_F(WebFrameTest, updateOverlayScrollbarLayers) @@ -1426,18 +1822,21 @@ TEST_F(WebFrameTest, updateOverlayScrollbarLayers) int viewWidth = 500; int viewHeight = 500; - createCompositingWebView(); - m_webView->resize(WebSize(viewWidth, viewHeight)); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "large-div.html"); + OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr(new FakeCompositingWebViewClient()); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, &fakeCompositingWebViewClient->m_fakeWebFrameClient, fakeCompositingWebViewClient.get(), &configueCompositingWebView); + + webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html"); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - m_webView->layout(); + webViewHelper.webView()->layout(); - WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); + WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar()); EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); - m_webView->resize(WebSize(viewWidth * 10, viewHeight * 10)); - m_webView->layout(); + webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); + webViewHelper.webView()->layout(); EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()); EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); } @@ -1456,13 +1855,14 @@ TEST_F(WebFrameTest, DivAutoZoomParamsTest) int viewportWidth = 640 / deviceScaleFactor; int viewportHeight = 1280 / deviceScaleFactor; float doubleTapZoomAlreadyLegibleRatio = 1.2f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html"); // - m_webView->setDeviceScaleFactor(deviceScaleFactor); - m_webView->setPageScaleFactorLimits(0.01f, 4); - m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->enableFixedLayoutMode(true); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html"); + webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); + webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); + webViewHelper.webView()->setPageScaleFactor(0.5f, WebPoint(0, 0)); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->layout(); WebRect wideDiv(200, 100, 400, 150); WebRect tallDiv(200, 300, 400, 800); @@ -1473,29 +1873,29 @@ TEST_F(WebFrameTest, DivAutoZoomParamsTest) float scale; WebPoint scroll; - float doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; // Test double-tap zooming into wide div. - wideBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointWide, false); - webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doubleTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, doubleTapZoomAlreadyLegibleScale, scale, scroll); + wideBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapPointWide, false); + webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doubleTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, doubleTapZoomAlreadyLegibleScale, scale, scroll); // The div should horizontally fill the screen (modulo margins), and // vertically centered (modulo integer rounding). EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); EXPECT_NEAR(wideDiv.x, scroll.x, 20); EXPECT_EQ(0, scroll.y); - setScaleAndScrollAndLayout(webViewImpl(), scroll, scale); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); // Test zoom out back to minimum scale. - wideBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointWide, false); - webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doubleTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, doubleTapZoomAlreadyLegibleScale, scale, scroll); + wideBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapPointWide, false); + webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doubleTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, doubleTapZoomAlreadyLegibleScale, scale, scroll); - scale = webViewImpl()->minimumPageScaleFactor(); - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), scale); + scale = webViewHelper.webViewImpl()->minimumPageScaleFactor(); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), scale); // Test double-tap zooming into tall div. - tallBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointTall, false); - webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doubleTapPointTall.x, doubleTapPointTall.y), tallBlockBounds, touchPointPadding, doubleTapZoomAlreadyLegibleScale, scale, scroll); + tallBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapPointTall, false); + webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doubleTapPointTall.x, doubleTapPointTall.y), tallBlockBounds, touchPointPadding, doubleTapZoomAlreadyLegibleScale, scale, scroll); // The div should start at the top left of the viewport. EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); EXPECT_NEAR(tallDiv.x, scroll.x, 20); @@ -1503,7 +1903,7 @@ TEST_F(WebFrameTest, DivAutoZoomParamsTest) // Test for Non-doubletap scaling // Test zooming into div. - webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250, 250), webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10), true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); + webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250, 250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10), true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); } @@ -1536,27 +1936,28 @@ TEST_F(WebFrameTest, DivAutoZoomWideDivTest) int viewportWidth = 640 / deviceScaleFactor; int viewportHeight = 1280 / deviceScaleFactor; float doubleTapZoomAlreadyLegibleRatio = 1.2f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->setPageScaleFactorLimits(1.0f, 4); - m_webView->setDeviceScaleFactor(deviceScaleFactor); - m_webView->setPageScaleFactor(1.0f, WebPoint(0, 0)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); + webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); + webViewHelper.webView()->setPageScaleFactor(1.0f, WebPoint(0, 0)); + webViewHelper.webView()->layout(); - webViewImpl()->enableFakePageScaleAnimationForTesting(true); + webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); - float doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; WebRect div(0, 100, viewportWidth, 150); WebPoint point(div.x + 50, div.y + 50); float scale; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), point, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); - simulateDoubleTap(webViewImpl(), point, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); } TEST_F(WebFrameTest, DivAutoZoomVeryTallTest) @@ -1569,21 +1970,22 @@ TEST_F(WebFrameTest, DivAutoZoomVeryTallTest) const float deviceScaleFactor = 2.0f; int viewportWidth = 640 / deviceScaleFactor; int viewportHeight = 1280 / deviceScaleFactor; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "very_tall_div.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->setPageScaleFactorLimits(1.0f, 4); - m_webView->setDeviceScaleFactor(deviceScaleFactor); - m_webView->setPageScaleFactor(1.0f, WebPoint(0, 0)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); + webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); + webViewHelper.webView()->setPageScaleFactor(1.0f, WebPoint(0, 0)); + webViewHelper.webView()->layout(); WebRect div(200, 300, 400, 5000); WebPoint point(div.x + 50, div.y + 3000); float scale; WebPoint scroll; - WebRect blockBounds = webViewImpl()->computeBlockBounds(WebRect(point.x, point.y, 0, 0), true); - webViewImpl()->computeScaleAndScrollForBlockRect(point, blockBounds, 0, 1.0f, scale, scroll); + WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRect(point.x, point.y, 0, 0), true); + webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockBounds, 0, 1.0f, scale, scroll); EXPECT_EQ(scale, 1.0f); EXPECT_EQ(scroll.y, 2660); } @@ -1596,45 +1998,46 @@ TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) int viewportWidth = 640 / deviceScaleFactor; int viewportHeight = 1280 / deviceScaleFactor; float doubleTapZoomAlreadyLegibleRatio = 1.2f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->setPageScaleFactorLimits(0.5f, 4); - m_webView->setDeviceScaleFactor(deviceScaleFactor); - m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); + webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); + webViewHelper.webView()->setPageScaleFactor(0.5f, WebPoint(0, 0)); + webViewHelper.webView()->layout(); - webViewImpl()->enableFakePageScaleAnimationForTesting(true); + webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); WebRect topDiv(200, 100, 200, 150); WebRect bottomDiv(200, 300, 200, 150); WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); float scale; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); // Test double tap on two different divs // After first zoom, we should go back to minimum page scale with a second double tap. - simulateDoubleTap(webViewImpl(), topPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); EXPECT_FLOAT_EQ(1, scale); - simulateDoubleTap(webViewImpl(), bottomPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); // If the user pinch zooms after double tap, a second double tap should zoom back to the div. - simulateDoubleTap(webViewImpl(), topPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); EXPECT_FLOAT_EQ(1, scale); - webViewImpl()->applyScrollAndScale(WebSize(), 0.6f); - simulateDoubleTap(webViewImpl(), bottomPoint, scale); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 0.6f); + simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); EXPECT_FLOAT_EQ(1, scale); - simulateDoubleTap(webViewImpl(), bottomPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); // If we didn't yet get an auto-zoom update and a second double-tap arrives, should go back to minimum scale. - webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); - webViewImpl()->animateDoubleTapZoom(topPoint); - EXPECT_TRUE(webViewImpl()->fakeDoubleTapAnimationPendingForTesting()); - simulateDoubleTap(webViewImpl(), bottomPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); + webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); + EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTesting()); + simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); } TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) @@ -1644,13 +2047,14 @@ TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) int viewportWidth = 320; int viewportHeight = 480; float doubleTapZoomAlreadyLegibleRatio = 1.2f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->setDeviceScaleFactor(1.5f); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->setDeviceScaleFactor(1.5f); + webViewHelper.webView()->layout(); - webViewImpl()->enableFakePageScaleAnimationForTesting(true); + webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); WebRect div(200, 100, 200, 150); WebPoint doubleTapPoint(div.x + 50, div.y + 50); @@ -1658,43 +2062,43 @@ TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) // Test double tap scale bounds. // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 - m_webView->setPageScaleFactorLimits(0.5f, 4); - m_webView->layout(); - float doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); + webViewHelper.webView()->layout(); + float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(1, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(1, scale); // Zoom in to reset double_tap_zoom_in_effect flag. - webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); // 1 < minimumPageScale < doubleTapZoomAlreadyLegibleScale - m_webView->setPageScaleFactorLimits(1.1f, 4); - m_webView->layout(); - doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + webViewHelper.webView()->setPageScaleFactorLimits(1.1f, 4); + webViewHelper.webView()->layout(); + doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); // Zoom in to reset double_tap_zoom_in_effect flag. - webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale - m_webView->setPageScaleFactorLimits(0.95f, 4); - m_webView->layout(); - doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + webViewHelper.webView()->setPageScaleFactorLimits(0.95f, 4); + webViewHelper.webView()->layout(); + doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); } @@ -1706,14 +2110,15 @@ TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) int viewportHeight = 480; float doubleTapZoomAlreadyLegibleRatio = 1.2f; float textAutosizingFontScaleFactor = 1.13f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); - webViewImpl()->enableFakePageScaleAnimationForTesting(true); - webViewImpl()->page()->settings().setTextAutosizingEnabled(true); - webViewImpl()->page()->settings().setTextAutosizingFontScaleFactor(textAutosizingFontScaleFactor); + webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); + webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(true); + webViewHelper.webViewImpl()->page()->settings().setTextAutosizingFontScaleFactor(textAutosizingFontScaleFactor); WebRect div(200, 100, 200, 150); WebPoint doubleTapPoint(div.x + 50, div.y + 50); @@ -1722,57 +2127,57 @@ TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) // Test double tap scale bounds. // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < textAutosizingFontScaleFactor float legibleScale = textAutosizingFontScaleFactor; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - float doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - m_webView->setPageScaleFactorLimits(0.5f, 4); - m_webView->layout(); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); + webViewHelper.webView()->layout(); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(legibleScale, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(legibleScale, scale); // Zoom in to reset double_tap_zoom_in_effect flag. - webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); // 1 < textAutosizingFontScaleFactor < minimumPageScale < doubleTapZoomAlreadyLegibleScale - m_webView->setPageScaleFactorLimits(1.0f, 4); - m_webView->layout(); - doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); + webViewHelper.webView()->layout(); + doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); // Zoom in to reset double_tap_zoom_in_effect flag. - webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); // minimumPageScale < 1 < textAutosizingFontScaleFactor < doubleTapZoomAlreadyLegibleScale - m_webView->setPageScaleFactorLimits(0.95f, 4); - m_webView->layout(); - doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + webViewHelper.webView()->setPageScaleFactorLimits(0.95f, 4); + webViewHelper.webView()->layout(); + doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); // Zoom in to reset double_tap_zoom_in_effect flag. - webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.1f); // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < textAutosizingFontScaleFactor - m_webView->setPageScaleFactorLimits(0.9f, 4); - m_webView->layout(); - doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + webViewHelper.webView()->setPageScaleFactorLimits(0.9f, 4); + webViewHelper.webView()->layout(); + doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(legibleScale, scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); - EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); - simulateDoubleTap(webViewImpl(), doubleTapPoint, scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); + EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale); + simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); EXPECT_FLOAT_EQ(legibleScale, scale); } @@ -1784,30 +2189,31 @@ TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) int viewportWidth = 640 / deviceScaleFactor; int viewportHeight = 1280 / deviceScaleFactor; float doubleTapZoomAlreadyLegibleRatio = 1.2f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->setPageScaleFactorLimits(0.5f, 4); - m_webView->setDeviceScaleFactor(deviceScaleFactor); - m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); + webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); + webViewHelper.webView()->setPageScaleFactor(0.5f, WebPoint(0, 0)); + webViewHelper.webView()->layout(); - webViewImpl()->enableFakePageScaleAnimationForTesting(true); + webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); WebRect viewportRect(0, 0, viewportWidth, viewportHeight); WebRect topDiv(200, 100, 200, 150); WebRect bottomDiv(200, 300, 200, 150); float scale; - setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), (webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (webViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); - simulateMultiTargetZoom(webViewImpl(), topDiv, scale); + simulateMultiTargetZoom(webViewHelper.webViewImpl(), topDiv, scale); EXPECT_FLOAT_EQ(1, scale); - simulateMultiTargetZoom(webViewImpl(), bottomDiv, scale); + simulateMultiTargetZoom(webViewHelper.webViewImpl(), bottomDiv, scale); EXPECT_FLOAT_EQ(1, scale); - simulateMultiTargetZoom(webViewImpl(), viewportRect, scale); + simulateMultiTargetZoom(webViewHelper.webViewImpl(), viewportRect, scale); EXPECT_FLOAT_EQ(1, scale); - webViewImpl()->setPageScaleFactor(webViewImpl()->minimumPageScaleFactor(), WebPoint(0, 0)); - simulateMultiTargetZoom(webViewImpl(), topDiv, scale); + webViewHelper.webViewImpl()->setPageScaleFactor(webViewHelper.webViewImpl()->minimumPageScaleFactor(), WebPoint(0, 0)); + simulateMultiTargetZoom(webViewHelper.webViewImpl(), topDiv, scale); EXPECT_FLOAT_EQ(1, scale); } @@ -1820,32 +2226,33 @@ TEST_F(WebFrameTest, DivScrollIntoEditableTest) float leftBoxRatio = 0.3f; int caretPadding = 10; float minReadableCaretHeight = 18.0f; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_zoom_into_editable_test.html"); - m_webView->enableFixedLayoutMode(true); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->setPageScaleFactorLimits(1, 4); - m_webView->layout(); - m_webView->setDeviceScaleFactor(1.5f); - m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editable_test.html"); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->setPageScaleFactorLimits(1, 4); + webViewHelper.webView()->layout(); + webViewHelper.webView()->setDeviceScaleFactor(1.5f); + webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(true); - webViewImpl()->enableFakePageScaleAnimationForTesting(true); + webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); WebRect editBoxWithText(200, 200, 250, 20); WebRect editBoxWithNoText(200, 250, 250, 20); // Test scrolling the focused node // The edit box is shorter and narrower than the viewport when legible. - m_webView->advanceFocus(false); + webViewHelper.webView()->advanceFocus(false); // Set the caret to the end of the input box. - m_webView->mainFrame()->document().getElementById("EditBoxWithText").to<WebInputElement>().setSelectionRange(1000, 1000); - setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); + webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWithText").to<WebInputElement>().setSelectionRange(1000, 1000); + setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); WebRect rect, caret; - webViewImpl()->selectionBounds(caret, rect); + webViewHelper.webViewImpl()->selectionBounds(caret, rect); float scale; WebCore::IntPoint scroll; bool needAnimation; - webViewImpl()->computeScaleAndScrollForFocusedNode(webViewImpl()->focusedElement(), scale, scroll, needAnimation); + webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelper.webViewImpl()->focusedElement(), scale, scroll, needAnimation); EXPECT_TRUE(needAnimation); // The edit box should be left aligned with a margin for possible label. int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; @@ -1857,21 +2264,21 @@ TEST_F(WebFrameTest, DivScrollIntoEditableTest) // The edit box is wider than the viewport when legible. viewportWidth = 200; viewportHeight = 150; - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); - webViewImpl()->selectionBounds(caret, rect); - webViewImpl()->computeScaleAndScrollForFocusedNode(webViewImpl()->focusedElement(), scale, scroll, needAnimation); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); + webViewHelper.webViewImpl()->selectionBounds(caret, rect); + webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelper.webViewImpl()->focusedElement(), scale, scroll, needAnimation); EXPECT_TRUE(needAnimation); // The caret should be right aligned since the caret would be offscreen when the edit box is left aligned. hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; EXPECT_NEAR(hScroll, scroll.x(), 1); EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); - setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); + setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); // Move focus to edit box with text. - m_webView->advanceFocus(false); - webViewImpl()->selectionBounds(caret, rect); - webViewImpl()->computeScaleAndScrollForFocusedNode(webViewImpl()->focusedElement(), scale, scroll, needAnimation); + webViewHelper.webView()->advanceFocus(false); + webViewHelper.webViewImpl()->selectionBounds(caret, rect); + webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelper.webViewImpl()->focusedElement(), scale, scroll, needAnimation); EXPECT_TRUE(needAnimation); // The edit box should be left aligned. hScroll = editBoxWithNoText.x; @@ -1880,11 +2287,11 @@ TEST_F(WebFrameTest, DivScrollIntoEditableTest) EXPECT_NEAR(vScroll, scroll.y(), 1); EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); - setScaleAndScrollAndLayout(webViewImpl(), scroll, scale); + setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); // Move focus back to the first edit box. - m_webView->advanceFocus(true); - webViewImpl()->computeScaleAndScrollForFocusedNode(webViewImpl()->focusedElement(), scale, scroll, needAnimation); + webViewHelper.webView()->advanceFocus(true); + webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelper.webViewImpl()->focusedElement(), scale, scroll, needAnimation); // The position should have stayed the same since this box was already on screen with the right scale. EXPECT_FALSE(needAnimation); } @@ -1907,15 +2314,13 @@ TEST_F(WebFrameTest, ReloadDoesntSetRedirect) registerMockedHttpURLLoad("form.html"); TestReloadDoesntRedirectWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.html", false, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameClient); - m_webView->mainFrame()->reload(true); + webViewHelper.webView()->mainFrame()->reload(true); // start reload before request is delivered. - m_webView->mainFrame()->reload(true); + webViewHelper.webView()->mainFrame()->reload(true); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) @@ -1931,25 +2336,26 @@ TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) registerMockedHttpURLLoad(secondURL); registerMockedHttpURLLoad(thirdURL); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + firstURL, true); - webViewImpl()->resize(WebSize(pageWidth, pageHeight)); - webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4)); - webViewImpl()->setPageScaleFactorPreservingScrollOffset(pageScaleFactor); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); + webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); + webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4)); + webViewHelper.webViewImpl()->setPageScaleFactorPreservingScrollOffset(pageScaleFactor); - WebSize previousOffset = webViewImpl()->mainFrame()->scrollOffset(); - float previousScale = webViewImpl()->pageScaleFactor(); + WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOffset(); + float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); // Reload the page using the cache. - webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondURL), false); + webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondURL), false); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - ASSERT_EQ(previousOffset, webViewImpl()->mainFrame()->scrollOffset()); - ASSERT_EQ(previousScale, webViewImpl()->pageScaleFactor()); + ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOffset()); + ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); // Reload the page while ignoring the cache. - webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + thirdURL), true); + webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + thirdURL), true); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - ASSERT_EQ(previousOffset, webViewImpl()->mainFrame()->scrollOffset()); - ASSERT_EQ(previousScale, webViewImpl()->pageScaleFactor()); + ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOffset()); + ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); } class TestReloadWhileProvisionalFrameClient : public WebFrameClient { @@ -1962,16 +2368,14 @@ TEST_F(WebFrameTest, ReloadWhileProvisional) registerMockedHttpURLLoad("fixed_layout.html"); TestReloadWhileProvisionalFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebView(false, &webFrameClient); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "fixed_layout.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(false, &webFrameClient); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html"); // start reload before first request is delivered. - m_webView->mainFrame()->reload(true); + webViewHelper.webView()->mainFrame()->reload(true); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); ASSERT_EQ(WebURL(toKURL(m_baseURL + "fixed_layout.html")), - m_webView->mainFrame()->dataSource()->request().url()); - - m_webView->close(); - m_webView = 0; + webViewHelper.webView()->mainFrame()->dataSource()->request().url()); } TEST_F(WebFrameTest, IframeRedirect) @@ -1979,10 +2383,11 @@ TEST_F(WebFrameTest, IframeRedirect) registerMockedHttpURLLoad("iframe_redirect.html"); registerMockedHttpURLLoad("visible_iframe.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_redirect.html", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); // Load the iframe. - WebFrame* iframe = m_webView->findFrameByName(WebString::fromUTF8("ifr")); + WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromUTF8("ifr")); ASSERT_TRUE(iframe); WebDataSource* iframeDataSource = iframe->dataSource(); ASSERT_TRUE(iframeDataSource); @@ -1998,13 +2403,14 @@ TEST_F(WebFrameTest, ClearFocusedNodeTest) registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_clear_focused_node_test.html", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "iframe_clear_focused_node_test.html", true); // Clear the focused node. - m_webView->clearFocusedNode(); + webViewHelper.webView()->clearFocusedNode(); // Now retrieve the FocusedNode and test it should be null. - EXPECT_EQ(0, webViewImpl()->focusedElement()); + EXPECT_EQ(0, webViewHelper.webViewImpl()->focusedElement()); } // Implementation of WebFrameClient that tracks the v8 contexts that are created @@ -2077,9 +2483,10 @@ TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) // Load a frame with an iframe, make sure we get the right create notifications. ContextLifetimeTestWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient); - WebFrame* mainFrame = m_webView->mainFrame(); + WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); WebFrame* childFrame = mainFrame->firstChild(); ASSERT_EQ(2u, webFrameClient.createNotifications.size()); @@ -2097,8 +2504,7 @@ TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) EXPECT_EQ(0, secondCreateNotification->worldId); // Close the view. We should get two release notifications that are exactly the same as the create ones, in reverse order. - m_webView->close(); - m_webView = 0; + webViewHelper.reset(); ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); ContextLifetimeTestWebFrameClient::Notification* firstReleaseNotification = webFrameClient.releaseNotifications[0]; @@ -2116,10 +2522,11 @@ TEST_F(WebFrameTest, ContextNotificationsReload) registerMockedHttpURLLoad("context_notifications_test_frame.html"); ContextLifetimeTestWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient); // Refresh, we should get two release notifications and two more create notifications. - m_webView->mainFrame()->reload(false); + webViewHelper.webView()->mainFrame()->reload(false); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); ASSERT_EQ(4u, webFrameClient.createNotifications.size()); ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); @@ -2131,7 +2538,7 @@ TEST_F(WebFrameTest, ContextNotificationsReload) } // The last two create notifications should be for the current frames and context. - WebFrame* mainFrame = m_webView->mainFrame(); + WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); WebFrame* childFrame = mainFrame->firstChild(); ContextLifetimeTestWebFrameClient::Notification* firstRefreshNotification = webFrameClient.createNotifications[2]; ContextLifetimeTestWebFrameClient::Notification* secondRefreshNotification = webFrameClient.createNotifications[3]; @@ -2143,9 +2550,6 @@ TEST_F(WebFrameTest, ContextNotificationsReload) EXPECT_EQ(childFrame, secondRefreshNotification->frame); EXPECT_EQ(childFrame->mainWorldScriptContext(), secondRefreshNotification->context); EXPECT_EQ(0, secondRefreshNotification->worldId); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) @@ -2157,7 +2561,8 @@ TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) registerMockedHttpURLLoad("context_notifications_test_frame.html"); ContextLifetimeTestWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient); // Add an isolated world. webFrameClient.reset(); @@ -2166,19 +2571,18 @@ TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) WebScriptSource scriptSource("hi!"); int numSources = 1; int extensionGroup = 0; - m_webView->mainFrame()->executeScriptInIsolatedWorld(isolatedWorldId, &scriptSource, numSources, extensionGroup); + webViewHelper.webView()->mainFrame()->executeScriptInIsolatedWorld(isolatedWorldId, &scriptSource, numSources, extensionGroup); // We should now have a new create notification. ASSERT_EQ(1u, webFrameClient.createNotifications.size()); ContextLifetimeTestWebFrameClient::Notification* notification = webFrameClient.createNotifications[0]; ASSERT_EQ(isolatedWorldId, notification->worldId); - ASSERT_EQ(m_webView->mainFrame(), notification->frame); + ASSERT_EQ(webViewHelper.webView()->mainFrame(), notification->frame); // We don't have an API to enumarate isolated worlds for a frame, but we can at least assert that the context we got is *not* the main world's context. - ASSERT_NE(m_webView->mainFrame()->mainWorldScriptContext(), v8::Local<v8::Context>::New(isolate, notification->context)); + ASSERT_NE(webViewHelper.webView()->mainFrame()->mainWorldScriptContext(), v8::Local<v8::Context>::New(isolate, notification->context)); - m_webView->close(); - m_webView = 0; + webViewHelper.reset(); // We should have gotten three release notifications (one for each of the frames, plus one for the isolated context). ASSERT_EQ(3u, webFrameClient.releaseNotifications.size()); @@ -2195,8 +2599,9 @@ TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) TEST_F(WebFrameTest, FindInPage) { registerMockedHttpURLLoad("find.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find.html"); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "find.html"); + WebFrame* frame = webViewHelper.webView()->mainFrame(); const int findIdentifier = 12345; WebFindOptions options; @@ -2250,11 +2655,12 @@ TEST_F(WebFrameTest, FindInPage) TEST_F(WebFrameTest, GetContentAsPlainText) { - m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:blank", true); // We set the size because it impacts line wrapping, which changes the // resulting text value. - m_webView->resize(WebSize(640, 480)); - WebFrame* frame = m_webView->mainFrame(); + webViewHelper.webView()->resize(WebSize(640, 480)); + WebFrame* frame = webViewHelper.webView()->mainFrame(); // Generate a simple test case. const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; @@ -2265,12 +2671,12 @@ TEST_F(WebFrameTest, GetContentAsPlainText) // Make sure it comes out OK. const std::string expected("Foo bar\nbaz"); WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); - EXPECT_EQ(expected, std::string(text.utf8().data())); + EXPECT_EQ(expected, text.utf8()); // Try reading the same one with clipping of the text. const int length = 5; text = frame->contentAsText(length); - EXPECT_EQ(expected.substr(0, length), std::string(text.utf8().data())); + EXPECT_EQ(expected.substr(0, length), text.utf8()); // Now do a new test with a subframe. const char outerFrameSource[] = "Hello<iframe></iframe> world"; @@ -2284,18 +2690,19 @@ TEST_F(WebFrameTest, GetContentAsPlainText) runPendingTasks(); text = frame->contentAsText(std::numeric_limits<size_t>::max()); - EXPECT_EQ("Hello world\n\nsub\ntext", std::string(text.utf8().data())); + EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); // Get the frame text where the subframe separator falls on the boundary of // what we'll take. There used to be a crash in this case. text = frame->contentAsText(12); - EXPECT_EQ("Hello world", std::string(text.utf8().data())); + EXPECT_EQ("Hello world", text.utf8()); } TEST_F(WebFrameTest, GetFullHtmlOfPage) { - m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:blank", true); + WebFrame* frame = webViewHelper.webView()->mainFrame(); // Generate a simple test case. const char simpleSource[] = "<p>Hello</p><p>World</p>"; @@ -2304,18 +2711,18 @@ TEST_F(WebFrameTest, GetFullHtmlOfPage) runPendingTasks(); WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); - EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8().data())); + EXPECT_EQ("Hello\n\nWorld", text.utf8()); - const std::string html = std::string(frame->contentAsMarkup().utf8().data()); + const std::string html = frame->contentAsMarkup().utf8(); // Load again with the output html. frame->loadHTMLString(WebData(html.c_str(), html.length()), testURL); runPendingTasks(); - EXPECT_EQ(html, std::string(frame->contentAsMarkup().utf8().data())); + EXPECT_EQ(html, frame->contentAsMarkup().utf8()); text = frame->contentAsText(std::numeric_limits<size_t>::max()); - EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8().data())); + EXPECT_EQ("Hello\n\nWorld", text.utf8()); // Test selection check EXPECT_FALSE(frame->hasSelection()); @@ -2340,13 +2747,11 @@ TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) registerMockedHttpURLLoad("hello_world.html"); TestExecuteScriptDuringDidCreateScriptContext webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html", true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFrameClient); - m_webView->mainFrame()->reload(); + webViewHelper.webView()->mainFrame()->reload(); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); - - m_webView->close(); - m_webView = 0; } class TestDidCreateFrameWebFrameClient : public WebFrameClient { @@ -2374,13 +2779,11 @@ TEST_F(WebFrameTest, DidCreateFrame) registerMockedHttpURLLoad("zero_sized_iframe.html"); TestDidCreateFrameWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html", false, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html", false, &webFrameClient); EXPECT_EQ(webFrameClient.m_frameCount, 3); - EXPECT_EQ(webFrameClient.m_parent, m_webView->mainFrame()); - - m_webView->close(); - m_webView = 0; + EXPECT_EQ(webFrameClient.m_parent, webViewHelper.webView()->mainFrame()); } class FindUpdateWebFrameClient : public WebFrameClient { @@ -2417,9 +2820,10 @@ TEST_F(WebFrameTest, FindInPageMatchRects) registerMockedHttpURLLoad("find_in_page_frame.html"); FindUpdateWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); - m_webView->resize(WebSize(640, 480)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &client); + webViewHelper.webView()->resize(WebSize(640, 480)); + webViewHelper.webView()->layout(); runPendingTasks(); // Note that the 'result 19' in the <select> element is not expected to produce a match. @@ -2429,7 +2833,7 @@ TEST_F(WebFrameTest, FindInPageMatchRects) WebFindOptions options; WebString searchText = WebString::fromUTF8(kFindString); - WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)); mainFrame->resetMatchCount(); @@ -2524,12 +2928,9 @@ TEST_F(WebFrameTest, FindInPageMatchRects) EXPECT_TRUE(webMatchRects[17].y > webMatchRects[18].y); // Resizing should update the rects version. - m_webView->resize(WebSize(800, 600)); + webViewHelper.webView()->resize(WebSize(800, 600)); runPendingTasks(); EXPECT_TRUE(mainFrame->findMatchMarkersVersion() != rectsVersion); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) @@ -2537,9 +2938,10 @@ TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) registerMockedHttpURLLoad("find_in_hidden_frame.html"); FindUpdateWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_hidden_frame.html", true, &client); - m_webView->resize(WebSize(640, 480)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "find_in_hidden_frame.html", true, &client); + webViewHelper.webView()->resize(WebSize(640, 480)); + webViewHelper.webView()->layout(); runPendingTasks(); static const char* kFindString = "hello"; @@ -2548,7 +2950,7 @@ TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) WebFindOptions options; WebString searchText = WebString::fromUTF8(kFindString); - WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)); mainFrame->resetMatchCount(); @@ -2559,9 +2961,6 @@ TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) runPendingTasks(); EXPECT_TRUE(client.findResultsAreReady()); EXPECT_EQ(kNumResults, client.count()); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, FindOnDetachedFrame) @@ -2570,9 +2969,10 @@ TEST_F(WebFrameTest, FindOnDetachedFrame) registerMockedHttpURLLoad("find_in_page_frame.html"); FindUpdateWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); - m_webView->resize(WebSize(640, 480)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &client); + webViewHelper.webView()->resize(WebSize(640, 480)); + webViewHelper.webView()->layout(); runPendingTasks(); static const char* kFindString = "result"; @@ -2580,7 +2980,7 @@ TEST_F(WebFrameTest, FindOnDetachedFrame) WebFindOptions options; WebString searchText = WebString::fromUTF8(kFindString); - WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); WebFrameImpl* secondFrame = toWebFrameImpl(mainFrame->traverseNext(false)); RefPtr<WebCore::Frame> holdSecondFrame = secondFrame->frame(); @@ -2602,9 +3002,6 @@ TEST_F(WebFrameTest, FindOnDetachedFrame) EXPECT_TRUE(client.findResultsAreReady()); holdSecondFrame.release(); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) @@ -2613,9 +3010,10 @@ TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) registerMockedHttpURLLoad("find_in_page_frame.html"); FindUpdateWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); - m_webView->resize(WebSize(640, 480)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &client); + webViewHelper.webView()->resize(WebSize(640, 480)); + webViewHelper.webView()->layout(); runPendingTasks(); static const char* kFindString = "result"; @@ -2623,7 +3021,7 @@ TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) WebFindOptions options; WebString searchText = WebString::fromUTF8(kFindString); - WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); WebFrameImpl* secondFrame = toWebFrameImpl(mainFrame->traverseNext(false)); RefPtr<WebCore::Frame> holdSecondFrame = secondFrame->frame(); @@ -2645,9 +3043,6 @@ TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) EXPECT_TRUE(client.findResultsAreReady()); holdSecondFrame.release(); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) @@ -2656,9 +3051,10 @@ TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) registerMockedHttpURLLoad("find_in_page_frame.html"); FindUpdateWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); - m_webView->resize(WebSize(640, 480)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &client); + webViewHelper.webView()->resize(WebSize(640, 480)); + webViewHelper.webView()->layout(); runPendingTasks(); static const char* kFindString = "result"; @@ -2666,7 +3062,7 @@ TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) WebFindOptions options; WebString searchText = WebString::fromUTF8(kFindString); - WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); WebFrameImpl* secondFrame = toWebFrameImpl(mainFrame->traverseNext(false)); RefPtr<WebCore::Frame> holdSecondFrame = secondFrame->frame(); @@ -2688,18 +3084,6 @@ TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) EXPECT_TRUE(client.findResultsAreReady()); holdSecondFrame.release(); - - m_webView->close(); - m_webView = 0; -} - -static WebView* createWebViewForTextSelection(const std::string& url) -{ - WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true); - webView->settings()->setDefaultFontSize(12); - webView->enableFixedLayoutMode(false); - webView->resize(WebSize(640, 480)); - return webView; } static WebPoint topLeft(const WebRect& rect) @@ -2723,7 +3107,7 @@ static WebRect elementBounds(WebFrame* frame, const WebString& id) static std::string selectionAsString(WebFrame* frame) { - return std::string(frame->selectionAsText().utf8().data()); + return frame->selectionAsText().utf8(); } TEST_F(WebFrameTest, SelectRange) @@ -2735,27 +3119,24 @@ TEST_F(WebFrameTest, SelectRange) registerMockedHttpURLLoad("select_range_basic.html"); registerMockedHttpURLLoad("select_range_scroll.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_basic.html"); - frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->executeCommand(WebString::fromUTF8("Unselect")); EXPECT_EQ("", selectionAsString(frame)); frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); - m_webView->close(); - m_webView = 0; - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_scroll.html"); - frame = m_webView->mainFrame(); + initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->executeCommand(WebString::fromUTF8("Unselect")); EXPECT_EQ("", selectionAsString(frame)); frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)); - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, SelectRangeInIframe) @@ -2767,17 +3148,16 @@ TEST_F(WebFrameTest, SelectRangeInIframe) registerMockedHttpURLLoad("select_range_iframe.html"); registerMockedHttpURLLoad("select_range_basic.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_iframe.html"); - frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); WebFrame* subframe = frame->findChildByExpression(WebString::fromUTF8("/html/body/iframe")); EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); subframe->executeCommand(WebString::fromUTF8("Unselect")); EXPECT_EQ("", selectionAsString(subframe)); subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, SelectRangeDivContentEditable) @@ -2790,30 +3170,27 @@ TEST_F(WebFrameTest, SelectRangeDivContentEditable) // Select the middle of an editable element, then try to extend the selection to the top of the document. // The selection range should be clipped to the bounds of the editable element. - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_editable.html"); - frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame)); - m_webView->close(); - m_webView = 0; // As above, but extending the selection to the bottom of the document. - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_editable.html"); - frame = m_webView->mainFrame(); + initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsString(frame)); - m_webView->close(); - m_webView = 0; } // positionForPoint returns the wrong values for contenteditable spans. See @@ -2828,38 +3205,36 @@ TEST_F(WebFrameTest, DISABLED_SelectRangeSpanContentEditable) // Select the middle of an editable element, then try to extend the selection to the top of the document. // The selection range should be clipped to the bounds of the editable element. - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_editable.html"); - frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame)); - m_webView->close(); - m_webView = 0; // As above, but extending the selection to the bottom of the document. - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_editable.html"); - frame = m_webView->mainFrame(); + initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html", &webViewHelper); + frame = webViewHelper.webView()->mainFrame(); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); - m_webView->selectionBounds(startWebRect, endWebRect); + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsString(frame)); - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart) { registerMockedHttpURLLoad("text_selection.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "text_selection.html"); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHelper); + WebFrame* frame = webViewHelper.webView()->mainFrame(); // Select second span. We can move the start to include the first span. frame->executeScript(WebScriptSource("selectElement('header_2');")); @@ -2905,8 +3280,9 @@ TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart) TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd) { registerMockedHttpURLLoad("text_selection.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "text_selection.html"); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHelper); + WebFrame* frame = webViewHelper.webView()->mainFrame(); // Select first span. We can move the end to include the second span. frame->executeScript(WebScriptSource("selectElement('header_1');")); @@ -2959,15 +3335,16 @@ static int computeOffset(WebCore::RenderObject* renderer, int x, int y) TEST_F(WebFrameTest, DISABLED_PositionForPointTest) { registerMockedHttpURLLoad("select_range_span_editable.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_editable.html"); - WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html", &webViewHelper); + WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); WebCore::RenderObject* renderer = mainFrame->frame()->selection().rootEditableElement()->renderer(); EXPECT_EQ(0, computeOffset(renderer, -1, -1)); EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); registerMockedHttpURLLoad("select_range_div_editable.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_editable.html"); - mainFrame = toWebFrameImpl(m_webView->mainFrame()); + initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); + mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); renderer = mainFrame->frame()->selection().rootEditableElement()->renderer(); EXPECT_EQ(0, computeOffset(renderer, -1, -1)); EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); @@ -2976,11 +3353,11 @@ TEST_F(WebFrameTest, DISABLED_PositionForPointTest) #if !OS(MACOSX) TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) { - WebFrameImpl* frame; registerMockedHttpURLLoad("move_caret.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "move_caret.html"); - frame = (WebFrameImpl*)m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper); + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); WebRect initialStartRect; WebRect initialEndRect; @@ -2988,18 +3365,18 @@ TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) WebRect endRect; frame->executeScript(WebScriptSource("selectRange();")); - m_webView->selectionBounds(initialStartRect, initialEndRect); + webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); WebPoint movedStart(topLeft(initialStartRect)); movedStart.y += 40; frame->selectRange(movedStart, bottomRightMinusOne(initialEndRect)); - m_webView->selectionBounds(startRect, endRect); + webViewHelper.webView()->selectionBounds(startRect, endRect); EXPECT_EQ(startRect, initialStartRect); EXPECT_EQ(endRect, initialEndRect); movedStart.y -= 80; frame->selectRange(movedStart, bottomRightMinusOne(initialEndRect)); - m_webView->selectionBounds(startRect, endRect); + webViewHelper.webView()->selectionBounds(startRect, endRect); EXPECT_EQ(startRect, initialStartRect); EXPECT_EQ(endRect, initialEndRect); @@ -3007,13 +3384,13 @@ TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) movedEnd.y += 40; frame->selectRange(topLeft(initialStartRect), movedEnd); - m_webView->selectionBounds(startRect, endRect); + webViewHelper.webView()->selectionBounds(startRect, endRect); EXPECT_EQ(startRect, initialStartRect); EXPECT_EQ(endRect, initialEndRect); movedEnd.y -= 80; frame->selectRange(topLeft(initialStartRect), movedEnd); - m_webView->selectionBounds(startRect, endRect); + webViewHelper.webView()->selectionBounds(startRect, endRect); EXPECT_EQ(startRect, initialStartRect); EXPECT_EQ(endRect, initialEndRect); } @@ -3023,8 +3400,9 @@ TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) WebFrameImpl* frame; registerMockedHttpURLLoad("move_caret.html"); - m_webView = createWebViewForTextSelection(m_baseURL + "move_caret.html"); - frame = (WebFrameImpl*)m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper); + frame = (WebFrameImpl*)webViewHelper.webView()->mainFrame(); WebRect initialStartRect; WebRect initialEndRect; @@ -3032,18 +3410,18 @@ TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) WebRect endRect; frame->executeScript(WebScriptSource("selectCaret();")); - m_webView->selectionBounds(initialStartRect, initialEndRect); + webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); WebPoint moveTo(topLeft(initialStartRect)); moveTo.y += 40; frame->moveCaretSelectionTowardsWindowPoint(moveTo); - m_webView->selectionBounds(startRect, endRect); + webViewHelper.webView()->selectionBounds(startRect, endRect); EXPECT_EQ(startRect, initialStartRect); EXPECT_EQ(endRect, initialEndRect); moveTo.y -= 80; frame->moveCaretSelectionTowardsWindowPoint(moveTo); - m_webView->selectionBounds(startRect, endRect); + webViewHelper.webView()->selectionBounds(startRect, endRect); EXPECT_EQ(startRect, initialStartRect); EXPECT_EQ(endRect, initialEndRect); } @@ -3083,21 +3461,22 @@ TEST_F(WebFrameTest, DisambiguationPopup) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(0, 0)); + webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); EXPECT_FALSE(client.triggered()); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(200, 115)); + webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); EXPECT_FALSE(client.triggered()); for (int i = 0; i <= 46; i++) { client.resetTriggered(); - m_webView->handleInputEvent(fatTap(120, 230 + i * 5)); + webViewHelper.webView()->handleInputEvent(fatTap(120, 230 + i * 5)); int j = i % 10; if (j >= 7 && j <= 9) @@ -3108,7 +3487,7 @@ TEST_F(WebFrameTest, DisambiguationPopup) for (int i = 0; i <= 46; i++) { client.resetTriggered(); - m_webView->handleInputEvent(fatTap(10 + i * 5, 590)); + webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); int j = i % 10; if (j >= 7 && j <= 9) @@ -3116,10 +3495,6 @@ TEST_F(WebFrameTest, DisambiguationPopup) else EXPECT_FALSE(client.triggered()); } - - m_webView->close(); - m_webView = 0; - } TEST_F(WebFrameTest, DisambiguationPopupNoContainer) @@ -3130,16 +3505,14 @@ TEST_F(WebFrameTest, DisambiguationPopupNoContainer) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "disambiguation_popup_no_container.html", true, 0, &client); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "disambiguation_popup_no_container.html", true, 0, &client); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(50, 50)); + webViewHelper.webView()->handleInputEvent(fatTap(50, 50)); EXPECT_FALSE(client.triggered()); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DisambiguationPopupMobileSite) @@ -3151,34 +3524,32 @@ TEST_F(WebFrameTest, DisambiguationPopupMobileSite) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(0, 0)); + webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); EXPECT_FALSE(client.triggered()); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(200, 115)); + webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); EXPECT_FALSE(client.triggered()); for (int i = 0; i <= 46; i++) { client.resetTriggered(); - m_webView->handleInputEvent(fatTap(120, 230 + i * 5)); + webViewHelper.webView()->handleInputEvent(fatTap(120, 230 + i * 5)); EXPECT_FALSE(client.triggered()); } for (int i = 0; i <= 46; i++) { client.resetTriggered(); - m_webView->handleInputEvent(fatTap(10 + i * 5, 590)); + webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); EXPECT_FALSE(client.triggered()); } - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DisambiguationPopupViewportSite) @@ -3190,34 +3561,32 @@ TEST_F(WebFrameTest, DisambiguationPopupViewportSite) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); - m_webView->enableFixedLayoutMode(true); - m_webView->settings()->setViewportEnabled(true); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); + webViewHelper.webView()->enableFixedLayoutMode(true); + webViewHelper.webView()->settings()->setViewportEnabled(true); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(0, 0)); + webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); EXPECT_FALSE(client.triggered()); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(200, 115)); + webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); EXPECT_FALSE(client.triggered()); for (int i = 0; i <= 46; i++) { client.resetTriggered(); - m_webView->handleInputEvent(fatTap(120, 230 + i * 5)); + webViewHelper.webView()->handleInputEvent(fatTap(120, 230 + i * 5)); EXPECT_FALSE(client.triggered()); } for (int i = 0; i <= 46; i++) { client.resetTriggered(); - m_webView->handleInputEvent(fatTap(10 + i * 5, 590)); + webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); EXPECT_FALSE(client.triggered()); } - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DisambiguationPopupBlacklist) @@ -3232,27 +3601,25 @@ TEST_F(WebFrameTest, DisambiguationPopupBlacklist) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); - m_webView->resize(WebSize(viewportWidth, viewportHeight)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); + webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); + webViewHelper.webView()->layout(); // Click somewhere where the popup shouldn't appear. client.resetTriggered(); - m_webView->handleInputEvent(fatTap(viewportWidth / 2, 0)); + webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, 0)); EXPECT_FALSE(client.triggered()); // Click directly in between two container divs with click handlers, with children that don't handle clicks. client.resetTriggered(); - m_webView->handleInputEvent(fatTap(viewportWidth / 2, divHeight)); + webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, divHeight)); EXPECT_TRUE(client.triggered()); // The third div container should be blacklisted if you click on the link it contains. client.resetTriggered(); - m_webView->handleInputEvent(fatTap(viewportWidth / 2, divHeight * 3.25)); + webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, divHeight * 3.25)); EXPECT_FALSE(client.triggered()); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DisambiguationPopupPageScale) @@ -3263,31 +3630,29 @@ TEST_F(WebFrameTest, DisambiguationPopupPageScale) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "disambiguation_popup_page_scale.html", true, 0, &client); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "disambiguation_popup_page_scale.html", true, 0, &client); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(80, 80)); + webViewHelper.webView()->handleInputEvent(fatTap(80, 80)); EXPECT_TRUE(client.triggered()); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(230, 190)); + webViewHelper.webView()->handleInputEvent(fatTap(230, 190)); EXPECT_TRUE(client.triggered()); - m_webView->setPageScaleFactor(3.0f, WebPoint(0, 0)); - m_webView->layout(); + webViewHelper.webView()->setPageScaleFactor(3.0f, WebPoint(0, 0)); + webViewHelper.webView()->layout(); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(240, 240)); + webViewHelper.webView()->handleInputEvent(fatTap(240, 240)); EXPECT_TRUE(client.triggered()); client.resetTriggered(); - m_webView->handleInputEvent(fatTap(690, 570)); + webViewHelper.webView()->handleInputEvent(fatTap(690, 570)); EXPECT_FALSE(client.triggered()); - - m_webView->close(); - m_webView = 0; } class TestSubstituteDataWebFrameClient : public WebFrameClient { @@ -3319,9 +3684,10 @@ TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) { TestSubstituteDataWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); runPendingTasks(); - WebFrame* frame = m_webView->mainFrame(); + WebFrame* frame = webViewHelper.webView()->mainFrame(); // Load a url as a history navigation that will return an error. TestSubstituteDataWebFrameClient // will start a SubstituteData load in response to the load failure, which should get fully committed. @@ -3345,11 +3711,8 @@ TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); - EXPECT_EQ("This should appear", std::string(text.utf8().data())); + EXPECT_EQ("This should appear", text.utf8()); EXPECT_TRUE(webFrameClient.commitCalled()); - - m_webView->close(); - m_webView = 0; } class TestWillInsertBodyWebFrameClient : public WebFrameClient { @@ -3383,13 +3746,11 @@ TEST_F(WebFrameTest, HTMLDocument) registerMockedHttpURLLoad("clipped-body.html"); TestWillInsertBodyWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "clipped-body.html", false, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "clipped-body.html", false, &webFrameClient); EXPECT_TRUE(webFrameClient.m_didLoad); EXPECT_EQ(1, webFrameClient.m_numBodies); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, EmptyDocument) @@ -3397,18 +3758,18 @@ TEST_F(WebFrameTest, EmptyDocument) registerMockedHttpURLLoad("pageserializer/green_rectangle.svg"); TestWillInsertBodyWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebView(false, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(false, &webFrameClient); EXPECT_FALSE(webFrameClient.m_didLoad); EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new frame starts with triggers this. - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) { - m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:blank", true); + WebFrame* frame = webViewHelper.webView()->mainFrame(); // This test passes if this doesn't crash. frame->moveCaretSelectionTowardsWindowPoint(WebPoint(0, 0)); @@ -3424,7 +3785,7 @@ public: Vector<WebTextCheckingResult> results; const int misspellingStartOffset = 1; const int misspellingLength = 8; - results.append(WebTextCheckingResult(WebTextCheckingTypeSpelling, misspellingStartOffset, misspellingLength, WebString(), m_hash)); + results.append(WebTextCheckingResult(WebTextDecorationTypeSpelling, misspellingStartOffset, misspellingLength, WebString(), m_hash)); completion->didFinishCheckingText(results); } int numberOfTimesChecked() const { return m_numberOfTimesChecked; } @@ -3436,17 +3797,18 @@ private: TEST_F(WebFrameTest, ReplaceMisspelledRange) { registerMockedHttpURLLoad("spell.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); SpellCheckClient spellcheck; - m_webView->setSpellCheckClient(&spellcheck); + webViewHelper.webView()->setSpellCheckClient(&spellcheck); - WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); Document* document = frame->frame()->document(); Element* element = document->getElementById("data"); - m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); - m_webView->settings()->setUnifiedTextCheckerEnabled(true); - m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); element->focus(); document->execCommand("InsertText", false, "_wellcome_."); @@ -3460,26 +3822,24 @@ TEST_F(WebFrameTest, ReplaceMisspelledRange) EXPECT_EQ(1U, document->markers()->markersInRange(selectionRange.get(), DocumentMarker::Spelling).size()); frame->replaceMisspelledRange("welcome"); - EXPECT_EQ("_welcome_.", std::string(frame->contentAsText(std::numeric_limits<size_t>::max()).utf8().data())); - - m_webView->close(); - m_webView = 0; + EXPECT_EQ("_welcome_.", frame->contentAsText(std::numeric_limits<size_t>::max()).utf8()); } TEST_F(WebFrameTest, RemoveSpellingMarkers) { registerMockedHttpURLLoad("spell.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); SpellCheckClient spellcheck; - m_webView->setSpellCheckClient(&spellcheck); + webViewHelper.webView()->setSpellCheckClient(&spellcheck); - WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); Document* document = frame->frame()->document(); Element* element = document->getElementById("data"); - m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); - m_webView->settings()->setUnifiedTextCheckerEnabled(true); - m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); element->focus(); document->execCommand("InsertText", false, "_wellcome_."); @@ -3492,37 +3852,32 @@ TEST_F(WebFrameTest, RemoveSpellingMarkers) RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange(); EXPECT_EQ(0U, document->markers()->markersInRange(selectionRange.get(), DocumentMarker::Spelling).size()); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, MarkerHashIdentifiers) { registerMockedHttpURLLoad("spell.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); static const uint32_t kHash = 42; SpellCheckClient spellcheck(kHash); - m_webView->setSpellCheckClient(&spellcheck); + webViewHelper.webView()->setSpellCheckClient(&spellcheck); - WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); Document* document = frame->frame()->document(); Element* element = document->getElementById("data"); - m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); - m_webView->settings()->setUnifiedTextCheckerEnabled(true); - m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); element->focus(); document->execCommand("InsertText", false, "wellcome."); WebVector<uint32_t> documentMarkers; - m_webView->spellingMarkers(&documentMarkers); + webViewHelper.webView()->spellingMarkers(&documentMarkers); EXPECT_EQ(1U, documentMarkers.size()); EXPECT_EQ(kHash, documentMarkers[0]); - - m_webView->close(); - m_webView = 0; } class StubbornSpellCheckClient : public WebSpellCheckClient { @@ -3539,38 +3894,58 @@ public: m_completion = completion; } + void kickNoResults() + { + kick(-1, -1, WebTextDecorationTypeSpelling); + } + void kick() { + kick(1, 8, WebTextDecorationTypeSpelling); + } + + void kickGrammar() + { + kick(1, 8, WebTextDecorationTypeGrammar); + } + + void kickInvisibleSpellcheck() + { + kick(1, 8, WebTextDecorationTypeInvisibleSpellcheck); + } + +private: + void kick(int misspellingStartOffset, int misspellingLength, WebTextDecorationType type) + { if (!m_completion) return; Vector<WebTextCheckingResult> results; - const int misspellingStartOffset = 1; - const int misspellingLength = 8; - results.append(WebTextCheckingResult(WebTextCheckingTypeSpelling, misspellingStartOffset, misspellingLength)); + if (misspellingStartOffset >= 0 && misspellingLength > 0) + results.append(WebTextCheckingResult(type, misspellingStartOffset, misspellingLength)); m_completion->didFinishCheckingText(results); m_completion = 0; } -private: WebKit::WebTextCheckingCompletion* m_completion; }; TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) { registerMockedHttpURLLoad("spell.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); StubbornSpellCheckClient spellcheck; - m_webView->setSpellCheckClient(&spellcheck); + webViewHelper.webView()->setSpellCheckClient(&spellcheck); - WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); WebInputElement webInputElement = frame->document().getElementById("data").to<WebInputElement>(); Document* document = frame->frame()->document(); Element* element = document->getElementById("data"); - m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); - m_webView->settings()->setUnifiedTextCheckerEnabled(true); - m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); element->focus(); document->execCommand("InsertText", false, "wellcome "); @@ -3580,11 +3955,8 @@ TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) spellcheck.kick(); WebVector<uint32_t> documentMarkers; - m_webView->spellingMarkers(&documentMarkers); + webViewHelper.webView()->spellingMarkers(&documentMarkers); EXPECT_EQ(0U, documentMarkers.size()); - - m_webView->close(); - m_webView = 0; } // This test verifies that cancelling spelling request does not cause a @@ -3592,23 +3964,91 @@ TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) TEST_F(WebFrameTest, CancelSpellingRequestCrash) { registerMockedHttpURLLoad("spell.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html"); - m_webView->setSpellCheckClient(0); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); + webViewHelper.webView()->setSpellCheckClient(0); - WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); Document* document = frame->frame()->document(); Element* element = document->getElementById("data"); - m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); - m_webView->settings()->setUnifiedTextCheckerEnabled(true); - m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); element->focus(); frame->frame()->editor().replaceSelectionWithText("A", false, false); - frame->frame()->editor().spellCheckRequester().cancelCheck(); + frame->frame()->spellChecker().cancelCheck(); +} + +TEST_F(WebFrameTest, SpellcheckResultErasesMarkers) +{ + registerMockedHttpURLLoad("spell.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); + + StubbornSpellCheckClient spellcheck; + webViewHelper.webView()->setSpellCheckClient(&spellcheck); + + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); + WebInputElement webInputElement = frame->document().getElementById("data").to<WebInputElement>(); + Document* document = frame->frame()->document(); + Element* element = document->getElementById("data"); + + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + + element->focus(); + document->execCommand("InsertText", false, "welcome "); + document->markers()->addMarker(rangeOfContents(element->toNode()).get(), DocumentMarker::Spelling); + document->markers()->addMarker(rangeOfContents(element->toNode()).get(), DocumentMarker::Grammar); + document->markers()->addMarker(rangeOfContents(element->toNode()).get(), DocumentMarker::InvisibleSpellcheck); + EXPECT_EQ(3U, document->markers()->markers().size()); + + spellcheck.kickNoResults(); + EXPECT_EQ(0U, document->markers()->markers().size()); +} + +TEST_F(WebFrameTest, SpellcheckResultsSavedInDocument) +{ + registerMockedHttpURLLoad("spell.html"); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); + + StubbornSpellCheckClient spellcheck; + webViewHelper.webView()->setSpellCheckClient(&spellcheck); + + WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); + WebInputElement webInputElement = frame->document().getElementById("data").to<WebInputElement>(); + Document* document = frame->frame()->document(); + Element* element = document->getElementById("data"); + + webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(true); + webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); + webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); + + element->focus(); + document->execCommand("InsertText", false, "wellcome "); + + spellcheck.kick(); + ASSERT_EQ(1U, document->markers()->markers().size()); + ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers()->markers()[0]); + EXPECT_EQ(DocumentMarker::Spelling, document->markers()->markers()[0]->type()); + + document->execCommand("InsertText", false, "wellcome "); + + spellcheck.kickGrammar(); + ASSERT_EQ(1U, document->markers()->markers().size()); + ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers()->markers()[0]); + EXPECT_EQ(DocumentMarker::Grammar, document->markers()->markers()[0]->type()); - m_webView->close(); - m_webView = 0; + document->execCommand("InsertText", false, "wellcome "); + + spellcheck.kickInvisibleSpellcheck(); + ASSERT_EQ(1U, document->markers()->markers().size()); + ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers()->markers()[0]); + EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers()->markers()[0]->type()); } class TestAccessInitialDocumentWebFrameClient : public WebFrameClient { @@ -3629,13 +4069,15 @@ public: TEST_F(WebFrameTest, DidAccessInitialDocumentBody) { TestAccessInitialDocumentWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, &webFrameClient); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); // Create another window that will try to access it. - WebView* newView = FrameTestHelpers::createWebView(true); - newView->mainFrame()->setOpener(m_webView->mainFrame()); + FrameTestHelpers::WebViewHelper newWebViewHelper; + WebView* newView = newWebViewHelper.initialize(true); + newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); @@ -3650,22 +4092,20 @@ TEST_F(WebFrameTest, DidAccessInitialDocumentBody) WebScriptSource("window.opener.document.body.innerHTML += 'Modified';")); runPendingTasks(); EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); - - newView->close(); - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DidAccessInitialDocumentNavigator) { TestAccessInitialDocumentWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, &webFrameClient); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); // Create another window that will try to access it. - WebView* newView = FrameTestHelpers::createWebView(true); - newView->mainFrame()->setOpener(m_webView->mainFrame()); + FrameTestHelpers::WebViewHelper newWebViewHelper; + WebView* newView = newWebViewHelper.initialize(true); + newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); @@ -3674,38 +4114,34 @@ TEST_F(WebFrameTest, DidAccessInitialDocumentNavigator) WebScriptSource("console.log(window.opener.navigator);")); runPendingTasks(); EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); - - newView->close(); - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) { TestAccessInitialDocumentWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, &webFrameClient); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); // Access the initial document from a javascript: URL. - FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Modified'))"); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Modified'))"); runPendingTasks(); EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) { TestAccessInitialDocumentWebFrameClient webFrameClient; - m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initialize(true, &webFrameClient); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); // Create another window that will try to access it. - WebView* newView = FrameTestHelpers::createWebView(true); - newView->mainFrame()->setOpener(m_webView->mainFrame()); + FrameTestHelpers::WebViewHelper newWebViewHelper; + WebView* newView = newWebViewHelper.initialize(true); + newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); runPendingTasks(); EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); @@ -3723,10 +4159,6 @@ TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) // Ensure that we don't notify again later. runPendingTasks(); EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); - - newView->close(); - m_webView->close(); - m_webView = 0; } class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient { @@ -3767,15 +4199,16 @@ TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) // Make sure we initialize to minimum scale, even if the window size // only becomes available after the load begins. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "long_scroll.html", true, &client); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &client); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); EXPECT_FALSE(client.wasUserScroll()); EXPECT_FALSE(client.wasProgrammaticScroll()); // Do a compositor scroll, verify that this is counted as a user scroll. - webViewImpl()->applyScrollAndScale(WebSize(0, 1), 1.1f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(0, 1), 1.1f); EXPECT_TRUE(client.wasUserScroll()); client.reset(); @@ -3783,23 +4216,23 @@ TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) EXPECT_FALSE(client.wasProgrammaticScroll()); // The page scale 1.0f and scroll. - webViewImpl()->applyScrollAndScale(WebSize(0, 1), 1.0f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(0, 1), 1.0f); EXPECT_TRUE(client.wasUserScroll()); client.reset(); // No scroll event if there is no scroll delta. - webViewImpl()->applyScrollAndScale(WebSize(), 1.0f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(), 1.0f); EXPECT_FALSE(client.wasUserScroll()); EXPECT_FALSE(client.wasProgrammaticScroll()); client.reset(); // Non zero page scale and scroll. - webViewImpl()->applyScrollAndScale(WebSize(9, 13), 0.6f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(9, 13), 0.6f); EXPECT_TRUE(client.wasUserScroll()); client.reset(); // Programmatic scroll. - WebFrameImpl* frameImpl = webViewImpl()->mainFrameImpl(); + WebFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); EXPECT_FALSE(client.wasUserScroll()); EXPECT_TRUE(client.wasProgrammaticScroll()); @@ -3810,9 +4243,6 @@ TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) EXPECT_FALSE(client.wasProgrammaticScroll()); EXPECT_FALSE(client.wasUserScroll()); client.reset(); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, CompositorScrollIsUserScrollShortPage) @@ -3822,22 +4252,20 @@ TEST_F(WebFrameTest, CompositorScrollIsUserScrollShortPage) TestMainFrameUserOrProgrammaticScrollFrameClient client; // Short page tests. - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "short_scroll.html", true, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "short_scroll.html", true, &client); - m_webView->resize(WebSize(1000, 1000)); - m_webView->layout(); + webViewHelper.webView()->resize(WebSize(1000, 1000)); + webViewHelper.webView()->layout(); EXPECT_FALSE(client.wasUserScroll()); EXPECT_FALSE(client.wasProgrammaticScroll()); // Non zero page scale and scroll. - webViewImpl()->applyScrollAndScale(WebSize(9, 13), 2.0f); + webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(9, 13), 2.0f); EXPECT_FALSE(client.wasProgrammaticScroll()); EXPECT_TRUE(client.wasUserScroll()); client.reset(); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, FirstPartyForCookiesForRedirect) @@ -3860,11 +4288,9 @@ TEST_F(WebFrameTest, FirstPartyForCookiesForRedirect) finalResponse.setMIMEType("text/html"); Platform::current()->unitTestSupport()->registerMockedURL(redirectURL, finalResponse, filePath); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "first_party_redirect.html", true); - EXPECT_TRUE(m_webView->mainFrame()->document().firstPartyForCookies() == redirectURL); - - m_webView->close(); - m_webView = 0; + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", true); + EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCookies() == redirectURL); } class TestNavigationPolicyWebFrameClient : public WebFrameClient { @@ -3880,27 +4306,26 @@ TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) { registerMockedHttpURLLoad("fragment_middle_click.html"); TestNavigationPolicyWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fragment_middle_click.html", true, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", true, &client); - WebCore::Document* document = webViewImpl()->page()->mainFrame()->document(); + WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame()->document(); WebCore::KURL destination = document->url(); destination.setFragmentIdentifier("test"); - RefPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCore::eventNames().clickEvent, false, false, + RefPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCore::EventTypeNames::click, false, false, document->defaultView(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 1, 0, 0); WebCore::FrameLoadRequest frameRequest(document->securityOrigin(), WebCore::ResourceRequest(destination)); frameRequest.setTriggeringEvent(event); - webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); - - m_webView->close(); - m_webView = 0; + webViewHelper.webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); } TEST_F(WebFrameTest, BackToReload) { registerMockedHttpURLLoad("fragment_middle_click.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fragment_middle_click.html", true); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", true); + WebFrame* frame = webViewHelper.webView()->mainFrame(); WebHistoryItem firstItem = frame->currentHistoryItem(); EXPECT_FALSE(firstItem.isNull()); @@ -3917,18 +4342,16 @@ TEST_F(WebFrameTest, BackToReload) frame->reload(); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->request().cachePolicy()); - - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, ReloadPost) { registerMockedHttpURLLoad("reload_post.html"); - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "reload_post.html", true); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); + WebFrame* frame = webViewHelper.webView()->mainFrame(); - FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.forms[0].submit()"); + FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.forms[0].submit()"); runPendingTasks(); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); EXPECT_FALSE(frame->previousHistoryItem().isNull()); @@ -3938,9 +4361,6 @@ TEST_F(WebFrameTest, ReloadPost) Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->request().cachePolicy()); EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationType()); - - m_webView->close(); - m_webView = 0; } class TestSameDocumentWebFrameClient : public WebFrameClient { @@ -3966,22 +4386,22 @@ TEST_F(WebFrameTest, NavigateToSame) { registerMockedHttpURLLoad("navigate_to_same.html"); TestSameDocumentWebFrameClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "navigate_to_same.html", true, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &client); EXPECT_FALSE(client.frameLoadTypeSameSeen()); - WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewImpl()->page()->mainFrame()->document()->url())); - webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); + WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewHelper.webViewImpl()->page()->mainFrame()->document()->url())); + webViewHelper.webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); EXPECT_TRUE(client.frameLoadTypeSameSeen()); - m_webView->close(); - m_webView = 0; } TEST_F(WebFrameTest, WebNodeImageContents) { - m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); - WebFrame* frame = m_webView->mainFrame(); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad("about:blank", true); + WebFrame* frame = webViewHelper.webView()->mainFrame(); static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90IAAAAAElFTkSuQmCC\">"; @@ -4034,13 +4454,93 @@ TEST_F(WebFrameTest, PushStateStartsAndStops) { registerMockedHttpURLLoad("push_state.html"); TestStartStopCallbackWebViewClient client; - m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.html", true, 0, &client); + FrameTestHelpers::WebViewHelper webViewHelper; + webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, 0, &client); runPendingTasks(); EXPECT_EQ(client.startLoadingCount(), 2); EXPECT_EQ(client.stopLoadingCount(), 2); - m_webView->close(); - m_webView = 0; +} + +class TestHistoryWebFrameClient : public WebFrameClient { +public: + TestHistoryWebFrameClient() + { + m_replacesCurrentHistoryItem = false; + m_frame = 0; + } + void didStartProvisionalLoad(WebFrame* frame) + { + WebDataSource* ds = frame->provisionalDataSource(); + m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); + m_frame = frame; + } + + bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } + WebFrame* frame() { return m_frame; } + +private: + bool m_replacesCurrentHistoryItem; + WebFrame* m_frame; +}; + +// Test which ensures that the first navigation in a subframe will always +// result in history entry being replaced and not a new one added. +TEST_F(WebFrameTest, FirstFrameNavigationReplacesHistory) +{ + registerMockedHttpURLLoad("history.html"); + registerMockedHttpURLLoad("find.html"); + + FrameTestHelpers::WebViewHelper webViewHelper; + TestHistoryWebFrameClient client; + webViewHelper.initializeAndLoad("about:blank", true, &client); + runPendingTasks(); + EXPECT_TRUE(client.replacesCurrentHistoryItem()); + + WebFrame* frame = webViewHelper.webView()->mainFrame(); + + FrameTestHelpers::loadFrame(frame, + "javascript:document.body.appendChild(document.createElement('iframe'))"); + // Need to call runPendingTasks in order for the JavaScript above to be + // evaluated and executed. + runPendingTasks(); + WebFrame* iframe = frame->firstChild(); + EXPECT_EQ(client.frame(), iframe); + EXPECT_TRUE(client.replacesCurrentHistoryItem()); + + FrameTestHelpers::loadFrame(frame, + "javascript:window.frames[0].location.assign('" + m_baseURL + "history.html')"); + runPendingTasks(); + Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); + EXPECT_EQ(client.frame(), iframe); + EXPECT_TRUE(client.replacesCurrentHistoryItem()); + + FrameTestHelpers::loadFrame(frame, + "javascript:window.frames[0].location.assign('" + m_baseURL + "find.html')"); + runPendingTasks(); + Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); + EXPECT_EQ(client.frame(), iframe); + EXPECT_FALSE(client.replacesCurrentHistoryItem()); + + // Repeat the test, but start out the iframe with initial URL, which is not + // "about:blank". + FrameTestHelpers::loadFrame(frame, + "javascript:var f = document.createElement('iframe'); " + "f.src = '" + m_baseURL + "history.html';" + "document.body.appendChild(f)"); + runPendingTasks(); + Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); + + iframe = frame->firstChild()->nextSibling(); + EXPECT_EQ(client.frame(), iframe); + EXPECT_TRUE(client.replacesCurrentHistoryItem()); + + FrameTestHelpers::loadFrame(frame, + "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html')"); + runPendingTasks(); + Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); + EXPECT_EQ(client.frame(), iframe); + EXPECT_FALSE(client.replacesCurrentHistoryItem()); } } // namespace diff --git a/Source/web/tests/WebImageTest.cpp b/Source/web/tests/WebImageTest.cpp index 24e9ffa5c..c7986dd7b 100644 --- a/Source/web/tests/WebImageTest.cpp +++ b/Source/web/tests/WebImageTest.cpp @@ -32,7 +32,7 @@ #include "public/platform/WebImage.h" #include <gtest/gtest.h> -#include "core/platform/SharedBuffer.h" +#include "platform/SharedBuffer.h" #include "public/platform/Platform.h" #include "public/platform/WebData.h" #include "public/platform/WebSize.h" diff --git a/Source/web/tests/WebInputEventConversionTest.cpp b/Source/web/tests/WebInputEventConversionTest.cpp index 9278071ae..f996595f9 100644 --- a/Source/web/tests/WebInputEventConversionTest.cpp +++ b/Source/web/tests/WebInputEventConversionTest.cpp @@ -44,8 +44,8 @@ #include "core/dom/Touch.h" #include "core/events/TouchEvent.h" #include "core/dom/TouchList.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" using namespace WebKit; using namespace WebCore; @@ -96,7 +96,8 @@ TEST(WebInputEventConversionTest, InputEventsScaling) const std::string fileName("fixed_layout.html"); URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("fixed_layout.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true)); + FrameTestHelpers::WebViewHelper webViewHelper; + WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(baseURL + fileName, true)); webViewImpl->enableFixedLayoutMode(true); webViewImpl->settings()->setViewportEnabled(true); int pageWidth = 640; @@ -186,6 +187,17 @@ TEST(WebInputEventConversionTest, InputEventsScaling) { WebGestureEvent webGestureEvent; + webGestureEvent.type = WebInputEvent::GestureShowPress; + webGestureEvent.data.tapDown.width = 10; + webGestureEvent.data.tapDown.height = 10; + + PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); + EXPECT_EQ(5, platformGestureBuilder.area().width()); + EXPECT_EQ(5, platformGestureBuilder.area().height()); + } + + { + WebGestureEvent webGestureEvent; webGestureEvent.type = WebInputEvent::GestureLongPress; webGestureEvent.data.longPress.width = 10; webGestureEvent.data.longPress.height = 10; @@ -231,7 +243,7 @@ TEST(WebInputEventConversionTest, InputEventsScaling) // which expect CSS pixel coordinates. { PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10), LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0); - RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::eventNames().mousemoveEvent, domWindow, platformMouseEvent, 0, document); + RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); WebMouseEventBuilder webMouseBuilder(view, docRenderer, *mouseEvent); EXPECT_EQ(10, webMouseBuilder.x); @@ -244,13 +256,13 @@ TEST(WebInputEventConversionTest, InputEventsScaling) { PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10), NoButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0); - RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::eventNames().mousemoveEvent, domWindow, platformMouseEvent, 0, document); + RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); WebMouseEventBuilder webMouseBuilder(view, docRenderer, *mouseEvent); EXPECT_EQ(WebMouseEvent::ButtonNone, webMouseBuilder.button); } { - PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUpdate, IntPoint(10, 10), IntPoint(10, 10), 0, IntSize(10, 10), FloatPoint(10, 10), false, false, false, false); + PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUpdate, IntPoint(10, 10), IntPoint(10, 10), IntSize(10, 10), 0, false, false, false, false, 10, 10, 10, 10); RefPtr<GestureEvent> gestureEvent = GestureEvent::create(domWindow, platformGestureEvent); WebGestureEventBuilder webGestureBuilder(view, docRenderer, *gestureEvent); @@ -266,7 +278,7 @@ TEST(WebInputEventConversionTest, InputEventsScaling) RefPtr<Touch> touch = Touch::create(webViewImpl->page()->mainFrame(), document.get(), 0, 10, 10, 10, 10, 10, 10, 0, 0); RefPtr<TouchList> touchList = TouchList::create(); touchList->append(touch); - RefPtr<TouchEvent> touchEvent = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), WebCore::eventNames().touchmoveEvent, domWindow, 10, 10, 10, 10, false, false, false, false); + RefPtr<TouchEvent> touchEvent = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), WebCore::EventTypeNames::touchmove, domWindow, 10, 10, 10, 10, false, false, false, false); WebTouchEventBuilder webTouchBuilder(view, docRenderer, *touchEvent); ASSERT_EQ(1u, webTouchBuilder.touchesLength); @@ -277,8 +289,6 @@ TEST(WebInputEventConversionTest, InputEventsScaling) EXPECT_EQ(10, webTouchBuilder.touches[0].radiusX); EXPECT_EQ(10, webTouchBuilder.touches[0].radiusY); } - - webViewImpl->close(); } } // anonymous namespace diff --git a/Source/web/tests/WebPageNewSerializerTest.cpp b/Source/web/tests/WebPageNewSerializerTest.cpp index 65afbdad3..f2f7c0c27 100644 --- a/Source/web/tests/WebPageNewSerializerTest.cpp +++ b/Source/web/tests/WebPageNewSerializerTest.cpp @@ -115,6 +115,7 @@ protected: { // Create and initialize the WebView. m_webView = WebView::create(0); + m_mainFrame = WebFrame::create(&m_webFrameClient); // We want the images to load and JavaScript to be on. WebSettings* settings = m_webView->settings(); @@ -122,13 +123,14 @@ protected: settings->setLoadsImagesAutomatically(true); settings->setJavaScriptEnabled(true); - m_webView->initializeMainFrame(&m_webFrameClient); + m_webView->setMainFrame(m_mainFrame); } virtual void TearDown() { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); m_webView->close(); + m_mainFrame->close(); } WebURL setUpCSSTestPage() @@ -189,6 +191,7 @@ private: WebString m_pngMimeType; WebString m_svgMimeType; TestWebFrameClient m_webFrameClient; + WebFrame* m_mainFrame; }; // Tests that a page with resources and sub-frame is reported with all its resources. diff --git a/Source/web/tests/WebPageSerializerTest.cpp b/Source/web/tests/WebPageSerializerTest.cpp index 924b75501..2c110cc5a 100644 --- a/Source/web/tests/WebPageSerializerTest.cpp +++ b/Source/web/tests/WebPageSerializerTest.cpp @@ -66,13 +66,15 @@ protected: { // Create and initialize the WebView. m_webView = WebView::create(0); - m_webView->initializeMainFrame(&m_webFrameClient); + m_mainFrame = WebFrame::create(&m_webFrameClient); + m_webView->setMainFrame(m_mainFrame); } virtual void TearDown() { Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); m_webView->close(); + m_mainFrame->close(); } void registerMockedURLLoad(const std::string& url, const WebString& fileName) @@ -107,6 +109,7 @@ protected: private: TestWebFrameClient m_webFrameClient; + WebFrame* m_mainFrame; }; TEST_F(WebPageSerializerTest, HTMLNodes) diff --git a/Source/web/tests/WebPluginContainerTest.cpp b/Source/web/tests/WebPluginContainerTest.cpp index 30bd62cf0..b115189e9 100644 --- a/Source/web/tests/WebPluginContainerTest.cpp +++ b/Source/web/tests/WebPluginContainerTest.cpp @@ -102,7 +102,8 @@ WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) TEST_F(WebPluginContainerTest, WindowToLocalPointTest) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient()); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient()); ASSERT(webView); webView->settings()->setPluginsEnabled(true); webView->resize(WebSize(300, 300)); @@ -126,14 +127,13 @@ TEST_F(WebPluginContainerTest, WindowToLocalPointTest) WebPoint point4 = pluginContainerTwo->windowToLocalPoint(WebPoint(-10, 10)); ASSERT_EQ(10, point4.x); ASSERT_EQ(10, point4.y); - - webView->close(); } TEST_F(WebPluginContainerTest, LocalToWindowPointTest) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient()); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient()); ASSERT(webView); webView->settings()->setPluginsEnabled(true); webView->resize(WebSize(300, 300)); @@ -157,15 +157,14 @@ TEST_F(WebPluginContainerTest, LocalToWindowPointTest) WebPoint point4 = pluginContainerTwo->localToWindowPoint(WebPoint(10, 10)); ASSERT_EQ(-10, point4.x); ASSERT_EQ(10, point4.y); - - webView->close(); } // Verifies executing the command 'Copy' results in copying to the clipboard. TEST_F(WebPluginContainerTest, Copy) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient()); + FrameTestHelpers::WebViewHelper webViewHelper; + WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient()); ASSERT(webView); webView->settings()->setPluginsEnabled(true); webView->resize(WebSize(300, 300)); @@ -175,8 +174,6 @@ TEST_F(WebPluginContainerTest, Copy) WebElement pluginContainerOneElement = webView->mainFrame()->document().getElementById(WebString::fromUTF8("translated-plugin")); EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOneElement)); EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer())); - - webView->close(); } } diff --git a/Source/web/tests/WebUserGestureTokenTest.cpp b/Source/web/tests/WebUserGestureTokenTest.cpp index 7b7bf1318..d6f454041 100644 --- a/Source/web/tests/WebUserGestureTokenTest.cpp +++ b/Source/web/tests/WebUserGestureTokenTest.cpp @@ -35,7 +35,7 @@ #include <gtest/gtest.h> #include "WebScopedUserGesture.h" #include "WebUserGestureIndicator.h" -#include "core/dom/UserGestureIndicator.h" +#include "platform/UserGestureIndicator.h" using namespace WebKit; using namespace WebCore; diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp index 0631e7b8a..5e6169a87 100644 --- a/Source/web/tests/WebViewTest.cpp +++ b/Source/web/tests/WebViewTest.cpp @@ -52,7 +52,7 @@ #include "core/dom/Element.h" #include "core/html/HTMLDocument.h" #include "core/loader/FrameLoadRequest.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Settings.h" #include "public/platform/Platform.h" #include "public/platform/WebSize.h" @@ -108,29 +108,6 @@ private: TestData m_testData; }; -class FormChangeWebViewClient : public WebViewClient { -public: - // WebViewClient methods - virtual void didChangeFormState(const WebNode& node) - { - m_focused = node.focused(); - m_called = true; - } - - // Local methods - void reset() - { - m_called = false; - m_focused = false; - } - bool called() { return m_called; } - bool focused() { return m_focused; } - -private: - bool m_called; - bool m_focused; -}; - class TapHandlingWebViewClient : public WebViewClient { public: // WebViewClient methods @@ -226,6 +203,7 @@ protected: void testInputMode(const WebString& expectedInputMode, const std::string& htmlFile); std::string m_baseURL; + FrameTestHelpers::WebViewHelper m_webViewHelper; }; TEST_F(WebViewTest, SetBaseBackgroundColor) @@ -235,7 +213,7 @@ TEST_F(WebViewTest, SetBaseBackgroundColor) const WebColor kDarkCyan = 0xFF227788; const WebColor kTranslucentPutty = 0x80BFB196; - WebView* webView = FrameTestHelpers::createWebView(); + WebView* webView = m_webViewHelper.initialize(); EXPECT_EQ(kWhite, webView->backgroundColor()); webView->setBaseBackgroundColor(kBlue); @@ -256,14 +234,12 @@ TEST_F(WebViewTest, SetBaseBackgroundColor) webView->setBaseBackgroundColor(kTranslucentPutty); // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); - - webView->close(); } TEST_F(WebViewTest, FocusIsInactive) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html"); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visible_iframe.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_iframe.html"); webView->setFocus(true); webView->setIsActive(true); @@ -284,14 +260,12 @@ TEST_F(WebViewTest, FocusIsInactive) webView->setFocus(false); webView->setIsActive(true); EXPECT_FALSE(document->hasFocus()); - - webView->close(); } TEST_F(WebViewTest, ActiveState) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html"); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visible_iframe.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_iframe.html"); ASSERT_TRUE(webView); @@ -303,15 +277,13 @@ TEST_F(WebViewTest, ActiveState) webView->setIsActive(true); EXPECT_TRUE(webView->isActive()); - - webView->close(); } TEST_F(WebViewTest, HitTestResultAtWithPageScale) { std::string url = m_baseURL + "specify_size.html?" + "50px" + ":" + "50px"; URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true, 0); + WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); webView->resize(WebSize(100, 100)); WebPoint hitPoint(75, 75); @@ -327,8 +299,6 @@ TEST_F(WebViewTest, HitTestResultAtWithPageScale) ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); EXPECT_TRUE(positiveResult.node().to<WebElement>().hasTagName("img")); positiveResult.reset(); - - webView->close(); } void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResize, @@ -339,7 +309,7 @@ void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma AutoResizeWebViewClient client; std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageHeight; URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true, 0, &client); + WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); client.testData().setWebView(webView); WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); @@ -360,7 +330,7 @@ void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma EXPECT_EQ(expectedHorizontalState, client.testData().horizontalScrollbarState()); EXPECT_EQ(expectedVerticalState, client.testData().verticalScrollbarState()); - webView->close(); + m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. } TEST_F(WebViewTest, DISABLED_AutoResizeMinimumSize) @@ -440,10 +410,9 @@ TEST_F(WebViewTest, DISABLED_AutoResizeMaxSize) void WebViewTest::testTextInputType(WebTextInputType expectedType, const std::string& htmlFile) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(htmlFile.c_str())); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); webView->setInitialFocus(false); EXPECT_EQ(expectedType, webView->textInputInfo().type); - webView->close(); } TEST_F(WebViewTest, TextInputType) @@ -460,10 +429,9 @@ TEST_F(WebViewTest, TextInputType) void WebViewTest::testInputMode(const WebString& expectedInputMode, const std::string& htmlFile) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(htmlFile.c_str())); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); webView->setInitialFocus(false); EXPECT_EQ(expectedInputMode, webView->textInputInfo().inputMode); - webView->close(); } TEST_F(WebViewTest, InputMode) @@ -480,7 +448,7 @@ TEST_F(WebViewTest, InputMode) TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setInitialFocus(false); webView->setEditableSelectionOffsets(5, 13); WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); @@ -491,10 +459,9 @@ TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) EXPECT_EQ(13, info.selectionEnd); EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); - webView->close(); URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("content_editable_populated.html")); - webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "content_editable_populated.html"); + webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_populated.html"); webView->setInitialFocus(false); webView->setEditableSelectionOffsets(8, 19); frame = toWebFrameImpl(webView->mainFrame()); @@ -505,13 +472,12 @@ TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) EXPECT_EQ(19, info.selectionEnd); EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); - webView->close(); } TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setInitialFocus(false); // Set up a composition that needs to be committed. @@ -548,14 +514,12 @@ TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange) EXPECT_EQ(8, info.selectionEnd); EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); - - webView->close(); } TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("text_area_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "text_area_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); webView->setInitialFocus(false); WebVector<WebCompositionUnderline> emptyUnderlines; @@ -585,30 +549,12 @@ TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); - - webView->close(); -} - -TEST_F(WebViewTest, FormChange) -{ - FormChangeWebViewClient client; - client.reset(); - URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_set_value_while_focused.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_set_value_while_focused.html", true, 0, &client); - EXPECT_TRUE(client.called()); - EXPECT_TRUE(client.focused()); - client.reset(); - URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_set_value_while_not_focused.html")); - webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_set_value_while_not_focused.html", true, 0, &client); - EXPECT_TRUE(client.called()); - EXPECT_FALSE(client.focused()); - webView->close(); } TEST_F(WebViewTest, ExtendSelectionAndDelete) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setInitialFocus(false); webView->setEditableSelectionOffsets(10, 10); webView->extendSelectionAndDelete(5, 8); @@ -619,13 +565,12 @@ TEST_F(WebViewTest, ExtendSelectionAndDelete) webView->extendSelectionAndDelete(10, 0); info = webView->textInputInfo(); EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); - webView->close(); } TEST_F(WebViewTest, SetCompositionFromExistingText) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setInitialFocus(false); WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); underlines[0] = WebKit::WebCompositionUnderline(0, 4, 0, false); @@ -646,13 +591,12 @@ TEST_F(WebViewTest, SetCompositionFromExistingText) EXPECT_EQ(10, info.selectionEnd); EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); - webView->close(); } TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("text_area_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "text_area_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); webView->setInitialFocus(false); WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); underlines[0] = WebKit::WebCompositionUnderline(0, 4, 0, false); @@ -682,13 +626,12 @@ TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) EXPECT_EQ(34, info.selectionEnd); EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); - webView->close(); } TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setInitialFocus(false); std::string compositionTextFirst("hello "); @@ -744,13 +687,12 @@ TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) EXPECT_EQ(2, info.selectionEnd); EXPECT_EQ(-1, info.compositionStart); EXPECT_EQ(-1, info.compositionEnd); - webView->close(); } TEST_F(WebViewTest, IsSelectionAnchorFirst) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); WebFrame* frame = webView->mainFrame(); webView->setInitialFocus(false); @@ -761,13 +703,12 @@ TEST_F(WebViewTest, IsSelectionAnchorFirst) webView->selectionBounds(anchor, focus); frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y)); EXPECT_FALSE(webView->isSelectionAnchorFirst()); - webView->close(); } TEST_F(WebViewTest, HistoryResetScrollAndScaleState) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("hello_world.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html")); + WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html")); webViewImpl->resize(WebSize(640, 480)); webViewImpl->layout(); EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); @@ -806,7 +747,6 @@ TEST_F(WebViewTest, HistoryResetScrollAndScaleState) EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); - webViewImpl->close(); } class EnterFullscreenWebViewClient : public WebViewClient { @@ -821,7 +761,7 @@ TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) { EnterFullscreenWebViewClient client; URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("hello_world.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html", true, 0, &client)); + WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, 0, &client)); webViewImpl->settings()->setFullScreenEnabled(true); webViewImpl->resize(WebSize(640, 480)); webViewImpl->layout(); @@ -854,7 +794,7 @@ TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); - webViewImpl->close(); + m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. } class ContentDetectorClient : public WebViewClient { @@ -922,7 +862,7 @@ TEST_F(WebViewTest, DetectContentAroundPosition) URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("content_listeners.html")); ContentDetectorClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "content_listeners.html", true, 0, &client); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_listeners.html", true, 0, &client); webView->resize(WebSize(500, 300)); webView->layout(); runPendingTasks(); @@ -964,14 +904,13 @@ TEST_F(WebViewTest, DetectContentAroundPosition) webView->handleInputEvent(event); runPendingTasks(); EXPECT_TRUE(client.pendingIntentsCancelled()); - webView->close(); } TEST_F(WebViewTest, ClientTapHandling) { TapHandlingWebViewClient client; client.reset(); - WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true, 0, &client); + WebView* webView = m_webViewHelper.initializeAndLoad("about:blank", true, 0, &client); WebGestureEvent event; event.type = WebInputEvent::GestureTap; event.x = 3; @@ -988,7 +927,8 @@ TEST_F(WebViewTest, ClientTapHandling) runPendingTasks(); EXPECT_EQ(25, client.longpressX()); EXPECT_EQ(7, client.longpressY()); - webView->close(); + + m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. } #if OS(ANDROID) @@ -996,7 +936,7 @@ TEST_F(WebViewTest, LongPressSelection) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("longpress_selection.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "longpress_selection.html", true); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_selection.html", true); webView->resize(WebSize(500, 300)); webView->layout(); runPendingTasks(); @@ -1009,14 +949,13 @@ TEST_F(WebViewTest, LongPressSelection) EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, target)); EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); - webView->close(); } #endif TEST_F(WebViewTest, SelectionOnDisabledInput) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("selection_disabled.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "selection_disabled.html", true); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "selection_disabled.html", true); webView->resize(WebSize(640, 480)); webView->layout(); runPendingTasks(); @@ -1031,14 +970,12 @@ TEST_F(WebViewTest, SelectionOnDisabledInput) EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length)); EXPECT_EQ(location, 0UL); EXPECT_EQ(length, testWord.length()); - - webView->close(); } TEST_F(WebViewTest, SelectionOnReadOnlyInput) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("selection_readonly.html")); - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "selection_readonly.html", true); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "selection_readonly.html", true); webView->resize(WebSize(640, 480)); webView->layout(); runPendingTasks(); @@ -1053,8 +990,6 @@ TEST_F(WebViewTest, SelectionOnReadOnlyInput) EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length)); EXPECT_EQ(location, 0UL); EXPECT_EQ(length, testWord.length()); - - webView->close(); } class MockAutofillClient : public WebAutofillClient { @@ -1095,7 +1030,7 @@ TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); MockAutofillClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setAutofillClient(&client); webView->setInitialFocus(false); @@ -1117,14 +1052,13 @@ TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) EXPECT_EQ(0, client.textChangesWhileNotIgnored()); webView->setAutofillClient(0); - webView->close(); } TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); MockAutofillClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html"); webView->setAutofillClient(&client); webView->setInitialFocus(false); @@ -1146,14 +1080,13 @@ TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange) EXPECT_EQ(1, client.textChangesWhileNotIgnored()); webView->setAutofillClient(0); - webView->close(); } TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); MockAutofillClient client; - WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html", true); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html", true); webView->setAutofillClient(&client); webView->setInitialFocus(false); @@ -1174,13 +1107,12 @@ TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) EXPECT_EQ(WebString::fromUTF8("none"), document.getElementById("inputEvent").firstChild().nodeValue()); webView->setAutofillClient(0); - webView->close(); } TEST_F(WebViewTest, ShadowRoot) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("shadow_dom_test.html")); - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "shadow_dom_test.html", true)); + WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(m_baseURL + "shadow_dom_test.html", true)); WebDocument document = webViewImpl->mainFrame()->document(); { @@ -1195,13 +1127,12 @@ TEST_F(WebViewTest, ShadowRoot) WebNode shadowRoot = elementWithoutShadowRoot.shadowRoot(); EXPECT_TRUE(shadowRoot.isNull()); } - webViewImpl->close(); } TEST_F(WebViewTest, HelperPlugin) { HelperPluginCreatingWebViewClient client; - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebView(true, 0, &client)); + WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initialize(true, 0, &client)); WebFrameImpl* frame = toWebFrameImpl(webViewImpl->mainFrame()); client.setWebFrameClient(frame->client()); @@ -1212,23 +1143,21 @@ TEST_F(WebViewTest, HelperPlugin) webViewImpl->closeHelperPluginSoon(helperPlugin); - webViewImpl->close(); + m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. } class ViewCreatingWebViewClient : public WebViewClient { public: ViewCreatingWebViewClient() - : m_createdWebView(0) - , m_didFocusCalled(false) + : m_didFocusCalled(false) { } // WebViewClient methods virtual WebView* createView(WebFrame*, const WebURLRequest&, const WebWindowFeatures&, const WebString& name, WebNavigationPolicy) OVERRIDE { - m_createdWebView = FrameTestHelpers::createWebView(true, 0, 0); - return m_createdWebView; + return m_webViewHelper.initialize(true, 0, 0); } // WebWidgetClient methods @@ -1237,23 +1166,19 @@ public: m_didFocusCalled = true; } - void close() - { - if (m_createdWebView) - m_createdWebView->close(); - } bool didFocusCalled() const { return m_didFocusCalled; } - WebView* createdWebView() const { return m_createdWebView; } + WebView* createdWebView() const { return m_webViewHelper.webView(); } private: - WebView* m_createdWebView; + FrameTestHelpers::WebViewHelper m_webViewHelper; bool m_didFocusCalled; }; TEST_F(WebViewTest, FocusExistingFrameOnNavigate) { ViewCreatingWebViewClient client; - WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebView(true, 0, &client)); + FrameTestHelpers::WebViewHelper m_webViewHelper; + WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initialize(true, 0, &client)); webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(true); WebFrameImpl* frame = toWebFrameImpl(webViewImpl->mainFrame()); frame->setName("_start"); @@ -1273,8 +1198,33 @@ TEST_F(WebViewTest, FocusExistingFrameOnNavigate) toWebViewImpl(client.createdWebView())->page()->mainFrame()->loader()->load(requestWithTargetStart); EXPECT_TRUE(client.didFocusCalled()); - client.close(); - webViewImpl->close(); + m_webViewHelper.reset(); // Remove dependency on locally scoped client. +} + +TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) +{ + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "focusout_focusin_events.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_focusin_events.html", true, 0); + + webView->setFocus(true); + webView->setFocus(false); + webView->setFocus(true); + + WebElement element = webView->mainFrame()->document().getElementById("message"); + EXPECT_STREQ("focusoutfocusin", element.innerText().utf8().data()); +} + +TEST_F(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) +{ + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "domfocusout_domfocusin_events.html"); + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "domfocusout_domfocusin_events.html", true, 0); + + webView->setFocus(true); + webView->setFocus(false); + webView->setFocus(true); + + WebElement element = webView->mainFrame()->document().getElementById("message"); + EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); } } diff --git a/Source/web/tests/data/domfocusout_domfocusin_events.html b/Source/web/tests/data/domfocusout_domfocusin_events.html new file mode 100644 index 000000000..ee215e0ed --- /dev/null +++ b/Source/web/tests/data/domfocusout_domfocusin_events.html @@ -0,0 +1,15 @@ +<input id="field" /> +<div id="message"></div> +<script> + var field = document.getElementById('field'); + + field.addEventListener('DOMFocusOut', function() { + document.getElementById('message').innerText += 'DOMFocusOut'; + + field.addEventListener('DOMFocusIn', function() { + document.getElementById('message').innerText += 'DOMFocusIn'; + }); + }); + + field.focus(); +</script> diff --git a/Source/web/tests/data/focusout_focusin_events.html b/Source/web/tests/data/focusout_focusin_events.html new file mode 100644 index 000000000..f278e541b --- /dev/null +++ b/Source/web/tests/data/focusout_focusin_events.html @@ -0,0 +1,15 @@ +<input id="field" /> +<div id="message"></div> +<script> + var field = document.getElementById('field'); + + field.addEventListener('focusout', function() { + document.getElementById('message').innerText += 'focusout'; + + field.addEventListener('focusin', function() { + document.getElementById('message').innerText += 'focusin'; + }); + }); + + field.focus(); +</script> diff --git a/Source/web/tests/data/input_field_set_value_while_focused.html b/Source/web/tests/data/input_field_set_value_while_focused.html deleted file mode 100644 index e6c73eaca..000000000 --- a/Source/web/tests/data/input_field_set_value_while_focused.html +++ /dev/null @@ -1,6 +0,0 @@ -<input id='field'/> -<script> - var field = document.getElementById('field'); - field.focus(); - field.value = 'some text'; -</script> diff --git a/Source/web/tests/data/input_field_set_value_while_not_focused.html b/Source/web/tests/data/input_field_set_value_while_not_focused.html deleted file mode 100644 index 4e578d44d..000000000 --- a/Source/web/tests/data/input_field_set_value_while_not_focused.html +++ /dev/null @@ -1,5 +0,0 @@ -<input id='field'/> -<script> - var field = document.getElementById('field'); - field.value = 'some text'; -</script> diff --git a/Source/web/tests/data/invalid-disposal-method.gif b/Source/web/tests/data/invalid-disposal-method.gif Binary files differnew file mode 100644 index 000000000..158f37677 --- /dev/null +++ b/Source/web/tests/data/invalid-disposal-method.gif diff --git a/Source/web/tests/data/viewport-initial-scale-less-than-1-device-width.html b/Source/web/tests/data/viewport-initial-scale-less-than-1-device-width.html new file mode 100644 index 000000000..990d727bf --- /dev/null +++ b/Source/web/tests/data/viewport-initial-scale-less-than-1-device-width.html @@ -0,0 +1,8 @@ +<html> + <head> + <meta name='viewport' content='width=device-width,target-densitydpi=device-dpi,initial-scale=0.25' /> + </head> + <body> + A page with a viewport set to device-dpi and device width, scale < 1. + </body> +</html> diff --git a/Source/web/tests/data/viewport-initial-scale-less-than-1.html b/Source/web/tests/data/viewport-initial-scale-less-than-1.html new file mode 100644 index 000000000..f4d4d50b9 --- /dev/null +++ b/Source/web/tests/data/viewport-initial-scale-less-than-1.html @@ -0,0 +1,8 @@ +<html> + <head> + <meta name='viewport' content='width=320,target-densitydpi=device-dpi,initial-scale=0.25' /> + </head> + <body> + A page with a viewport set to device-dpi and fixed width, scale < 1. + </body> +</html> diff --git a/Source/web/tests/data/viewport-target-densitydpi-device-and-fixed-width.html b/Source/web/tests/data/viewport-target-densitydpi-device-and-fixed-width.html new file mode 100644 index 000000000..06cc3e32b --- /dev/null +++ b/Source/web/tests/data/viewport-target-densitydpi-device-and-fixed-width.html @@ -0,0 +1,8 @@ +<html> + <head> + <meta name='viewport' content='width=640,target-densityDpi=device-dpi,initial-scale=1.0' /> + </head> + <body> + A page with a viewport set to device-dpi and fixed width, fixed scale. + </body> +</html> diff --git a/Source/web/tests/data/wide_document_width_viewport.html b/Source/web/tests/data/wide_document_width_viewport.html new file mode 100644 index 000000000..e16bf1e39 --- /dev/null +++ b/Source/web/tests/data/wide_document_width_viewport.html @@ -0,0 +1,8 @@ +<html> + <head> + <meta name='viewport' content='width=device-width,initial-scale=0.25' /> + </head> + <body style="margin:0px;"> + <img width="800px" height="800px" src="white-1x1.png">Wide img forcing page to widen</img> + </body> +</html> diff --git a/Source/web/web.gyp b/Source/web/web.gyp index 96ef54538..1529ee002 100644 --- a/Source/web/web.gyp +++ b/Source/web/web.gyp @@ -33,7 +33,7 @@ '../build/win/precompile.gypi', '../bindings/bindings.gypi', '../core/core.gypi', - '../core/features.gypi', + '../build/features.gypi', '../modules/modules.gypi', '../wtf/wtf.gypi', 'web.gypi', @@ -44,14 +44,15 @@ 'type': '<(component)', 'variables': { 'enable_wexit_time_destructors': 1, }, 'dependencies': [ + 'picker_resources', + '../platform/blink_platform.gyp:blink_common', '../core/core.gyp:webcore', '../modules/modules.gyp:modules', '<(DEPTH)/skia/skia.gyp:skia', - '<(DEPTH)/third_party/angle_dx11/src/build_angle.gyp:translator_glsl', + '<(DEPTH)/third_party/angle_dx11/src/build_angle.gyp:translator', '<(DEPTH)/third_party/icu/icu.gyp:icuuc', '<(DEPTH)/third_party/npapi/npapi.gyp:npapi', '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', - 'blink_common', ], 'export_dependent_settings': [ '<(DEPTH)/skia/skia.gyp:skia', @@ -67,7 +68,7 @@ ], 'defines': [ 'BLINK_IMPLEMENTATION=1', - 'INSIDE_WEBKIT', + 'INSIDE_BLINK', ], 'sources': [ '<@(webcore_platform_support_files)', @@ -264,30 +265,89 @@ ], }, { - 'target_name': 'blink_common', - 'type': '<(component)', - 'variables': { 'enable_wexit_time_destructors': 1 }, - 'dependencies': [ - '../wtf/wtf.gyp:wtf', - '<(DEPTH)/skia/skia.gyp:skia', - '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', - ], - 'export_dependent_settings': [ - '<(DEPTH)/skia/skia.gyp:skia', - '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', - ], - 'defines': [ - 'INSIDE_WEBKIT', - 'BLINK_COMMON_IMPLEMENTATION=1', - ], - 'include_dirs': [ - '..', - '../..', - ], - 'sources': [ - '../core/platform/chromium/support/WebCString.cpp', - '../core/platform/chromium/support/WebString.cpp', - 'WebCommon.cpp', + 'target_name': 'picker_resources', + 'type': 'none', + 'hard_dependency': 1, + 'variables': { + 'make_file_arrays': 'scripts/make-file-arrays.py', + }, + 'actions': [ + { + 'action_name': 'PickerCommon', + 'variables': { + 'resources': [ + 'resources/pickerCommon.css', + 'resources/pickerCommon.js', + ], + }, + 'inputs': [ + '<(make_file_arrays)', + '<@(resources)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/blink/PickerCommon.h', + '<(SHARED_INTERMEDIATE_DIR)/blink/PickerCommon.cpp', + ], + 'action': [ + 'python', + '<(make_file_arrays)', + '--out-h=<(SHARED_INTERMEDIATE_DIR)/blink/PickerCommon.h', + '--out-cpp=<(SHARED_INTERMEDIATE_DIR)/blink/PickerCommon.cpp', + '<@(resources)', + ], + }, + { + 'action_name': 'CalendarPicker', + 'variables': { + 'resources': [ + 'resources/calendarPicker.css', + 'resources/calendarPicker.js', + 'resources/pickerButton.css', + 'resources/suggestionPicker.css', + 'resources/suggestionPicker.js', + ], + }, + 'inputs': [ + '<(make_file_arrays)', + '<@(resources)' + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/blink/CalendarPicker.h', + '<(SHARED_INTERMEDIATE_DIR)/blink/CalendarPicker.cpp', + ], + 'action': [ + 'python', + '<(make_file_arrays)', + '--condition=ENABLE(CALENDAR_PICKER)', + '--out-h=<(SHARED_INTERMEDIATE_DIR)/blink/CalendarPicker.h', + '--out-cpp=<(SHARED_INTERMEDIATE_DIR)/blink/CalendarPicker.cpp', + '<@(resources)', + ], + }, + { + 'action_name': 'ColorSuggestionPicker', + 'variables': { + 'resources': [ + 'resources/colorSuggestionPicker.css', + 'resources/colorSuggestionPicker.js', + ], + }, + 'inputs': [ + '<(make_file_arrays)', + '<@(resources)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/blink/ColorSuggestionPicker.h', + '<(SHARED_INTERMEDIATE_DIR)/blink/ColorSuggestionPicker.cpp', + ], + 'action': [ + 'python', + '<(make_file_arrays)', + '--out-h=<(SHARED_INTERMEDIATE_DIR)/blink/ColorSuggestionPicker.h', + '--out-cpp=<(SHARED_INTERMEDIATE_DIR)/blink/ColorSuggestionPicker.cpp', + '<@(resources)', + ], + }, ], }, ], # targets diff --git a/Source/web/web.gypi b/Source/web/web.gypi index f5909e660..58dad6563 100644 --- a/Source/web/web.gypi +++ b/Source/web/web.gypi @@ -28,8 +28,6 @@ 'DatabaseObserver.cpp', 'DateTimeChooserImpl.cpp', 'DateTimeChooserImpl.h', - 'DeviceOrientationClientProxy.cpp', - 'DeviceOrientationClientProxy.h', 'DragClientImpl.cpp', 'DragClientImpl.h', 'EditorClientImpl.cpp', @@ -76,6 +74,8 @@ 'PageOverlay.h', 'PageOverlayList.cpp', 'PageOverlayList.h', + 'PageScaleConstraintsSet.cpp', + 'PageScaleConstraintsSet.h', 'PageWidgetDelegate.cpp', 'PageWidgetDelegate.h', 'PinchViewports.cpp', @@ -124,6 +124,7 @@ 'WebDOMEventListener.cpp', 'WebDOMEventListenerPrivate.cpp', 'WebDOMEventListenerPrivate.h', + 'WebDOMFileSystem.cpp', 'WebDOMMessageEvent.cpp', 'WebDOMMouseEvent.cpp', 'WebDOMMutationEvent.cpp', @@ -136,9 +137,6 @@ 'WebDevToolsAgentImpl.h', 'WebDevToolsFrontendImpl.cpp', 'WebDevToolsFrontendImpl.h', - 'WebDeviceOrientation.cpp', - 'WebDeviceOrientationClientMock.cpp', - 'WebDeviceOrientationController.cpp', 'WebDocument.cpp', 'WebDocumentType.cpp', 'WebDragData.cpp', @@ -240,6 +238,7 @@ 'WebSpeechRecognitionResult.cpp', 'WebStorageEventDispatcherImpl.cpp', 'WebSurroundingText.cpp', + 'WebTextAreaElement.cpp', 'WebTextCheckingCompletionImpl.cpp', 'WebTextCheckingCompletionImpl.h', 'WebTextCheckingResult.cpp', @@ -278,6 +277,7 @@ 'web_unittest_files': [ 'tests/AssociatedURLLoaderTest.cpp', 'tests/ChromeClientImplTest.cpp', + 'tests/CompositedLayerMappingTest.cpp', 'tests/CustomEventTest.cpp', 'tests/DragImageTest.cpp', 'tests/FakeWebPlugin.cpp', @@ -300,8 +300,6 @@ 'tests/PopupContainerTest.cpp', 'tests/PrerenderingTest.cpp', 'tests/ProgrammaticScrollTest.cpp', - 'tests/RegionTest.cpp', - 'tests/RenderLayerBackingTest.cpp', 'tests/RenderTableCellTest.cpp', 'tests/RenderTableRowTest.cpp', 'tests/ScrollingCoordinatorChromiumTest.cpp', diff --git a/Source/web/web_tests.gyp b/Source/web/web_tests.gyp index 2bec9debd..dfc778a37 100644 --- a/Source/web/web_tests.gyp +++ b/Source/web/web_tests.gyp @@ -32,7 +32,7 @@ 'includes': [ '../bindings/bindings.gypi', '../core/core.gypi', - '../core/features.gypi', + '../build/features.gypi', '../modules/modules.gypi', '../web/web.gypi', '../wtf/wtf.gypi', @@ -68,7 +68,7 @@ 'conditions': [ ['component=="shared_library"', { 'defines': [ - 'WEBKIT_DLL_UNITTEST', + 'BLINK_DLL_UNITTEST', ], }, { 'dependencies': [ @@ -76,7 +76,7 @@ ], 'defines': [ 'BLINK_IMPLEMENTATION=1', - 'INSIDE_WEBKIT', + 'INSIDE_BLINK', ], 'sources': [ '<@(bindings_unittest_files)', diff --git a/Source/web/webkit.target.darwin-arm.mk b/Source/web/webkit.target.darwin-arm.mk index f0a3c068a..92655b651 100644 --- a/Source/web/webkit.target.darwin-arm.mk +++ b/Source/web/webkit.target.darwin-arm.mk @@ -11,6 +11,7 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ + $(call intermediates-dir-for,GYP,third_party_WebKit_Source_web_picker_resources_gyp)/picker_resources.stamp \ $(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_gyp)/webcore.stamp \ $(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \ $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ @@ -29,15 +30,12 @@ LOCAL_GENERATED_SOURCES := GYP_COPIED_SOURCE_ORIGIN_DIRS := LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/Platform.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebActiveGestureAnimation.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebArrayBuffer.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebAudioBus.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCrypto.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoKey.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCursorInfo.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceMotionData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebFileSystemCallbacks.cpp \ @@ -60,15 +58,12 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebSocketStreamError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSourceInfo.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebThreadSafeData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebTransformKeyframe.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURL.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURLError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLRequest.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLResponse.cpp \ third_party/WebKit/Source/web/ApplicationCacheHost.cpp \ @@ -85,7 +80,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp \ third_party/WebKit/Source/web/DatabaseObserver.cpp \ third_party/WebKit/Source/web/DateTimeChooserImpl.cpp \ - third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp \ third_party/WebKit/Source/web/DragClientImpl.cpp \ third_party/WebKit/Source/web/EditorClientImpl.cpp \ third_party/WebKit/Source/web/EventListenerWrapper.cpp \ @@ -109,6 +103,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/NotificationPresenterImpl.cpp \ third_party/WebKit/Source/web/PageOverlay.cpp \ third_party/WebKit/Source/web/PageOverlayList.cpp \ + third_party/WebKit/Source/web/PageScaleConstraintsSet.cpp \ third_party/WebKit/Source/web/PageWidgetDelegate.cpp \ third_party/WebKit/Source/web/PinchViewports.cpp \ third_party/WebKit/Source/web/PopupContainer.cpp \ @@ -141,6 +136,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDOMEvent.cpp \ third_party/WebKit/Source/web/WebDOMEventListener.cpp \ third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp \ + third_party/WebKit/Source/web/WebDOMFileSystem.cpp \ third_party/WebKit/Source/web/WebDOMMessageEvent.cpp \ third_party/WebKit/Source/web/WebDOMMouseEvent.cpp \ third_party/WebKit/Source/web/WebDOMMutationEvent.cpp \ @@ -150,9 +146,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDatabase.cpp \ third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp \ third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientation.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationController.cpp \ third_party/WebKit/Source/web/WebDocument.cpp \ third_party/WebKit/Source/web/WebDocumentType.cpp \ third_party/WebKit/Source/web/WebDragData.cpp \ @@ -234,6 +227,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp \ third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp \ third_party/WebKit/Source/web/WebSurroundingText.cpp \ + third_party/WebKit/Source/web/WebTextAreaElement.cpp \ third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp \ third_party/WebKit/Source/web/WebTextCheckingResult.cpp \ third_party/WebKit/Source/web/WebTextInputInfo.cpp \ @@ -304,20 +298,19 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ @@ -450,20 +443,19 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ diff --git a/Source/web/webkit.target.darwin-mips.mk b/Source/web/webkit.target.darwin-mips.mk index 47ce4c93e..f99e10e7c 100644 --- a/Source/web/webkit.target.darwin-mips.mk +++ b/Source/web/webkit.target.darwin-mips.mk @@ -11,6 +11,7 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ + $(call intermediates-dir-for,GYP,third_party_WebKit_Source_web_picker_resources_gyp)/picker_resources.stamp \ $(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_gyp)/webcore.stamp \ $(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \ $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ @@ -29,15 +30,12 @@ LOCAL_GENERATED_SOURCES := GYP_COPIED_SOURCE_ORIGIN_DIRS := LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/Platform.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebActiveGestureAnimation.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebArrayBuffer.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebAudioBus.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCrypto.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoKey.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCursorInfo.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceMotionData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebFileSystemCallbacks.cpp \ @@ -60,15 +58,12 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebSocketStreamError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSourceInfo.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebThreadSafeData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebTransformKeyframe.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURL.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURLError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLRequest.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLResponse.cpp \ third_party/WebKit/Source/web/ApplicationCacheHost.cpp \ @@ -85,7 +80,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp \ third_party/WebKit/Source/web/DatabaseObserver.cpp \ third_party/WebKit/Source/web/DateTimeChooserImpl.cpp \ - third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp \ third_party/WebKit/Source/web/DragClientImpl.cpp \ third_party/WebKit/Source/web/EditorClientImpl.cpp \ third_party/WebKit/Source/web/EventListenerWrapper.cpp \ @@ -109,6 +103,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/NotificationPresenterImpl.cpp \ third_party/WebKit/Source/web/PageOverlay.cpp \ third_party/WebKit/Source/web/PageOverlayList.cpp \ + third_party/WebKit/Source/web/PageScaleConstraintsSet.cpp \ third_party/WebKit/Source/web/PageWidgetDelegate.cpp \ third_party/WebKit/Source/web/PinchViewports.cpp \ third_party/WebKit/Source/web/PopupContainer.cpp \ @@ -141,6 +136,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDOMEvent.cpp \ third_party/WebKit/Source/web/WebDOMEventListener.cpp \ third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp \ + third_party/WebKit/Source/web/WebDOMFileSystem.cpp \ third_party/WebKit/Source/web/WebDOMMessageEvent.cpp \ third_party/WebKit/Source/web/WebDOMMouseEvent.cpp \ third_party/WebKit/Source/web/WebDOMMutationEvent.cpp \ @@ -150,9 +146,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDatabase.cpp \ third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp \ third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientation.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationController.cpp \ third_party/WebKit/Source/web/WebDocument.cpp \ third_party/WebKit/Source/web/WebDocumentType.cpp \ third_party/WebKit/Source/web/WebDragData.cpp \ @@ -234,6 +227,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp \ third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp \ third_party/WebKit/Source/web/WebSurroundingText.cpp \ + third_party/WebKit/Source/web/WebTextAreaElement.cpp \ third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp \ third_party/WebKit/Source/web/WebTextCheckingResult.cpp \ third_party/WebKit/Source/web/WebTextInputInfo.cpp \ @@ -303,20 +297,19 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ @@ -448,20 +441,19 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ diff --git a/Source/web/webkit.target.darwin-x86.mk b/Source/web/webkit.target.darwin-x86.mk index 847f92083..ef0b728ee 100644 --- a/Source/web/webkit.target.darwin-x86.mk +++ b/Source/web/webkit.target.darwin-x86.mk @@ -11,6 +11,7 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ + $(call intermediates-dir-for,GYP,third_party_WebKit_Source_web_picker_resources_gyp)/picker_resources.stamp \ $(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_gyp)/webcore.stamp \ $(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \ $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ @@ -29,15 +30,12 @@ LOCAL_GENERATED_SOURCES := GYP_COPIED_SOURCE_ORIGIN_DIRS := LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/Platform.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebActiveGestureAnimation.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebArrayBuffer.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebAudioBus.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCrypto.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoKey.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCursorInfo.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceMotionData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebFileSystemCallbacks.cpp \ @@ -60,15 +58,12 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebSocketStreamError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSourceInfo.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebThreadSafeData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebTransformKeyframe.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURL.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURLError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLRequest.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLResponse.cpp \ third_party/WebKit/Source/web/ApplicationCacheHost.cpp \ @@ -85,7 +80,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp \ third_party/WebKit/Source/web/DatabaseObserver.cpp \ third_party/WebKit/Source/web/DateTimeChooserImpl.cpp \ - third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp \ third_party/WebKit/Source/web/DragClientImpl.cpp \ third_party/WebKit/Source/web/EditorClientImpl.cpp \ third_party/WebKit/Source/web/EventListenerWrapper.cpp \ @@ -109,6 +103,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/NotificationPresenterImpl.cpp \ third_party/WebKit/Source/web/PageOverlay.cpp \ third_party/WebKit/Source/web/PageOverlayList.cpp \ + third_party/WebKit/Source/web/PageScaleConstraintsSet.cpp \ third_party/WebKit/Source/web/PageWidgetDelegate.cpp \ third_party/WebKit/Source/web/PinchViewports.cpp \ third_party/WebKit/Source/web/PopupContainer.cpp \ @@ -141,6 +136,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDOMEvent.cpp \ third_party/WebKit/Source/web/WebDOMEventListener.cpp \ third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp \ + third_party/WebKit/Source/web/WebDOMFileSystem.cpp \ third_party/WebKit/Source/web/WebDOMMessageEvent.cpp \ third_party/WebKit/Source/web/WebDOMMouseEvent.cpp \ third_party/WebKit/Source/web/WebDOMMutationEvent.cpp \ @@ -150,9 +146,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDatabase.cpp \ third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp \ third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientation.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationController.cpp \ third_party/WebKit/Source/web/WebDocument.cpp \ third_party/WebKit/Source/web/WebDocumentType.cpp \ third_party/WebKit/Source/web/WebDragData.cpp \ @@ -234,6 +227,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp \ third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp \ third_party/WebKit/Source/web/WebSurroundingText.cpp \ + third_party/WebKit/Source/web/WebTextAreaElement.cpp \ third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp \ third_party/WebKit/Source/web/WebTextCheckingResult.cpp \ third_party/WebKit/Source/web/WebTextInputInfo.cpp \ @@ -306,20 +300,19 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ @@ -455,20 +448,19 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ diff --git a/Source/web/webkit.target.linux-arm.mk b/Source/web/webkit.target.linux-arm.mk index f0a3c068a..92655b651 100644 --- a/Source/web/webkit.target.linux-arm.mk +++ b/Source/web/webkit.target.linux-arm.mk @@ -11,6 +11,7 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ + $(call intermediates-dir-for,GYP,third_party_WebKit_Source_web_picker_resources_gyp)/picker_resources.stamp \ $(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_gyp)/webcore.stamp \ $(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \ $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ @@ -29,15 +30,12 @@ LOCAL_GENERATED_SOURCES := GYP_COPIED_SOURCE_ORIGIN_DIRS := LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/Platform.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebActiveGestureAnimation.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebArrayBuffer.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebAudioBus.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCrypto.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoKey.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCursorInfo.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceMotionData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebFileSystemCallbacks.cpp \ @@ -60,15 +58,12 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebSocketStreamError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSourceInfo.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebThreadSafeData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebTransformKeyframe.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURL.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURLError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLRequest.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLResponse.cpp \ third_party/WebKit/Source/web/ApplicationCacheHost.cpp \ @@ -85,7 +80,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp \ third_party/WebKit/Source/web/DatabaseObserver.cpp \ third_party/WebKit/Source/web/DateTimeChooserImpl.cpp \ - third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp \ third_party/WebKit/Source/web/DragClientImpl.cpp \ third_party/WebKit/Source/web/EditorClientImpl.cpp \ third_party/WebKit/Source/web/EventListenerWrapper.cpp \ @@ -109,6 +103,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/NotificationPresenterImpl.cpp \ third_party/WebKit/Source/web/PageOverlay.cpp \ third_party/WebKit/Source/web/PageOverlayList.cpp \ + third_party/WebKit/Source/web/PageScaleConstraintsSet.cpp \ third_party/WebKit/Source/web/PageWidgetDelegate.cpp \ third_party/WebKit/Source/web/PinchViewports.cpp \ third_party/WebKit/Source/web/PopupContainer.cpp \ @@ -141,6 +136,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDOMEvent.cpp \ third_party/WebKit/Source/web/WebDOMEventListener.cpp \ third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp \ + third_party/WebKit/Source/web/WebDOMFileSystem.cpp \ third_party/WebKit/Source/web/WebDOMMessageEvent.cpp \ third_party/WebKit/Source/web/WebDOMMouseEvent.cpp \ third_party/WebKit/Source/web/WebDOMMutationEvent.cpp \ @@ -150,9 +146,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDatabase.cpp \ third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp \ third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientation.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationController.cpp \ third_party/WebKit/Source/web/WebDocument.cpp \ third_party/WebKit/Source/web/WebDocumentType.cpp \ third_party/WebKit/Source/web/WebDragData.cpp \ @@ -234,6 +227,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp \ third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp \ third_party/WebKit/Source/web/WebSurroundingText.cpp \ + third_party/WebKit/Source/web/WebTextAreaElement.cpp \ third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp \ third_party/WebKit/Source/web/WebTextCheckingResult.cpp \ third_party/WebKit/Source/web/WebTextInputInfo.cpp \ @@ -304,20 +298,19 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ @@ -450,20 +443,19 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ diff --git a/Source/web/webkit.target.linux-mips.mk b/Source/web/webkit.target.linux-mips.mk index 47ce4c93e..f99e10e7c 100644 --- a/Source/web/webkit.target.linux-mips.mk +++ b/Source/web/webkit.target.linux-mips.mk @@ -11,6 +11,7 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ + $(call intermediates-dir-for,GYP,third_party_WebKit_Source_web_picker_resources_gyp)/picker_resources.stamp \ $(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_gyp)/webcore.stamp \ $(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \ $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ @@ -29,15 +30,12 @@ LOCAL_GENERATED_SOURCES := GYP_COPIED_SOURCE_ORIGIN_DIRS := LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/Platform.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebActiveGestureAnimation.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebArrayBuffer.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebAudioBus.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCrypto.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoKey.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCursorInfo.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceMotionData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebFileSystemCallbacks.cpp \ @@ -60,15 +58,12 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebSocketStreamError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSourceInfo.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebThreadSafeData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebTransformKeyframe.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURL.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURLError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLRequest.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLResponse.cpp \ third_party/WebKit/Source/web/ApplicationCacheHost.cpp \ @@ -85,7 +80,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp \ third_party/WebKit/Source/web/DatabaseObserver.cpp \ third_party/WebKit/Source/web/DateTimeChooserImpl.cpp \ - third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp \ third_party/WebKit/Source/web/DragClientImpl.cpp \ third_party/WebKit/Source/web/EditorClientImpl.cpp \ third_party/WebKit/Source/web/EventListenerWrapper.cpp \ @@ -109,6 +103,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/NotificationPresenterImpl.cpp \ third_party/WebKit/Source/web/PageOverlay.cpp \ third_party/WebKit/Source/web/PageOverlayList.cpp \ + third_party/WebKit/Source/web/PageScaleConstraintsSet.cpp \ third_party/WebKit/Source/web/PageWidgetDelegate.cpp \ third_party/WebKit/Source/web/PinchViewports.cpp \ third_party/WebKit/Source/web/PopupContainer.cpp \ @@ -141,6 +136,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDOMEvent.cpp \ third_party/WebKit/Source/web/WebDOMEventListener.cpp \ third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp \ + third_party/WebKit/Source/web/WebDOMFileSystem.cpp \ third_party/WebKit/Source/web/WebDOMMessageEvent.cpp \ third_party/WebKit/Source/web/WebDOMMouseEvent.cpp \ third_party/WebKit/Source/web/WebDOMMutationEvent.cpp \ @@ -150,9 +146,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDatabase.cpp \ third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp \ third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientation.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationController.cpp \ third_party/WebKit/Source/web/WebDocument.cpp \ third_party/WebKit/Source/web/WebDocumentType.cpp \ third_party/WebKit/Source/web/WebDragData.cpp \ @@ -234,6 +227,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp \ third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp \ third_party/WebKit/Source/web/WebSurroundingText.cpp \ + third_party/WebKit/Source/web/WebTextAreaElement.cpp \ third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp \ third_party/WebKit/Source/web/WebTextCheckingResult.cpp \ third_party/WebKit/Source/web/WebTextInputInfo.cpp \ @@ -303,20 +297,19 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ @@ -448,20 +441,19 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ diff --git a/Source/web/webkit.target.linux-x86.mk b/Source/web/webkit.target.linux-x86.mk index 847f92083..ef0b728ee 100644 --- a/Source/web/webkit.target.linux-x86.mk +++ b/Source/web/webkit.target.linux-x86.mk @@ -11,6 +11,7 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ + $(call intermediates-dir-for,GYP,third_party_WebKit_Source_web_picker_resources_gyp)/picker_resources.stamp \ $(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_gyp)/webcore.stamp \ $(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \ $(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \ @@ -29,15 +30,12 @@ LOCAL_GENERATED_SOURCES := GYP_COPIED_SOURCE_ORIGIN_DIRS := LOCAL_SRC_FILES := \ - third_party/WebKit/Source/core/platform/chromium/support/Platform.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebActiveGestureAnimation.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebArrayBuffer.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebAudioBus.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCrypto.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCryptoKey.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebCursorInfo.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceMotionData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebFileSystemCallbacks.cpp \ @@ -60,15 +58,12 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebSocketStreamError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSourceInfo.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebThreadSafeData.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebTransformKeyframe.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURL.cpp \ - third_party/WebKit/Source/core/platform/chromium/support/WebURLError.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLRequest.cpp \ third_party/WebKit/Source/core/platform/chromium/support/WebURLResponse.cpp \ third_party/WebKit/Source/web/ApplicationCacheHost.cpp \ @@ -85,7 +80,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp \ third_party/WebKit/Source/web/DatabaseObserver.cpp \ third_party/WebKit/Source/web/DateTimeChooserImpl.cpp \ - third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp \ third_party/WebKit/Source/web/DragClientImpl.cpp \ third_party/WebKit/Source/web/EditorClientImpl.cpp \ third_party/WebKit/Source/web/EventListenerWrapper.cpp \ @@ -109,6 +103,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/NotificationPresenterImpl.cpp \ third_party/WebKit/Source/web/PageOverlay.cpp \ third_party/WebKit/Source/web/PageOverlayList.cpp \ + third_party/WebKit/Source/web/PageScaleConstraintsSet.cpp \ third_party/WebKit/Source/web/PageWidgetDelegate.cpp \ third_party/WebKit/Source/web/PinchViewports.cpp \ third_party/WebKit/Source/web/PopupContainer.cpp \ @@ -141,6 +136,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDOMEvent.cpp \ third_party/WebKit/Source/web/WebDOMEventListener.cpp \ third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp \ + third_party/WebKit/Source/web/WebDOMFileSystem.cpp \ third_party/WebKit/Source/web/WebDOMMessageEvent.cpp \ third_party/WebKit/Source/web/WebDOMMouseEvent.cpp \ third_party/WebKit/Source/web/WebDOMMutationEvent.cpp \ @@ -150,9 +146,6 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebDatabase.cpp \ third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp \ third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientation.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp \ - third_party/WebKit/Source/web/WebDeviceOrientationController.cpp \ third_party/WebKit/Source/web/WebDocument.cpp \ third_party/WebKit/Source/web/WebDocumentType.cpp \ third_party/WebKit/Source/web/WebDragData.cpp \ @@ -234,6 +227,7 @@ LOCAL_SRC_FILES := \ third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp \ third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp \ third_party/WebKit/Source/web/WebSurroundingText.cpp \ + third_party/WebKit/Source/web/WebTextAreaElement.cpp \ third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp \ third_party/WebKit/Source/web/WebTextCheckingResult.cpp \ third_party/WebKit/Source/web/WebTextInputInfo.cpp \ @@ -306,20 +300,19 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ @@ -455,20 +448,19 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DUSE_PROPRIETARY_CODECS' \ '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ '-DBLINK_IMPLEMENTATION=1' \ - '-DINSIDE_WEBKIT' \ + '-DINSIDE_BLINK' \ '-DENABLE_CSS3_TEXT=0' \ '-DENABLE_CSS_EXCLUSIONS=1' \ '-DENABLE_CSS_REGIONS=1' \ '-DENABLE_CUSTOM_SCHEME_HANDLER=0' \ '-DENABLE_ENCRYPTED_MEDIA_V2=1' \ '-DENABLE_SVG_FONTS=1' \ + '-DENABLE_GDI_FONTS_ON_WINDOWS=0' \ '-DENABLE_TOUCH_ICON_LOADING=1' \ - '-DENABLE_GDI_FONTS_ON_WINDOWS=1' \ '-DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1' \ '-DENABLE_CALENDAR_PICKER=0' \ '-DENABLE_FAST_MOBILE_SCROLLING=1' \ |