diff options
Diffstat (limited to 'Source/WebKit/chromium')
33 files changed, 726 insertions, 267 deletions
diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 851e43976..08b5cd5cf 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,308 @@ +2012-09-19 Adam Barth <abarth@webkit.org> + + Remove webkitPostMessage + https://bugs.webkit.org/show_bug.cgi?id=96577 + + Reviewed by Ojan Vafai. + + Actually disable webkitPostMessage. See + http://trac.webkit.org/changeset/128658 for more information. + + * features.gypi: + +2012-09-19 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Remove "current transaction" concept from backing store + https://bugs.webkit.org/show_bug.cgi?id=96663 + + Reviewed by Tony Chang. + + Update fake class with new method signatures. + + * tests/IDBFakeBackingStore.h: + +2012-09-19 Terry Anderson <tdanderson@chromium.org> + + [chromium] Store the contents scale factor in PlatformContextSkia on initialization + https://bugs.webkit.org/show_bug.cgi?id=96137 + + Reviewed by Stephen White. + + Define SK_SUPPORT_HINTING_SCALE_FACTOR by default. This is also used + for the skia patch here: https://codereview.appspot.com/6506099/. + Also added two new unit tests. + + * features.gypi: + * tests/OpaqueRectTrackingContentLayerDelegateTest.cpp: + (WebCore): + (WebCore::HintingScaleCallback::HintingScaleCallback): + (HintingScaleCallback): + (WebCore::HintingScaleCallback::operator()): + (WebCore::TEST_F): + * tests/PlatformContextSkiaTest.cpp: + (WebCore): + (WebCore::TEST): + +2012-09-19 David Grogan <dgrogan@chromium.org> + + Disable some failing IDB tests + https://bugs.webkit.org/show_bug.cgi?id=97135 + + Reviewed by Nate Chapin. + + They were broken in r129037. + + * tests/IDBDatabaseBackendTest.cpp: + +2012-09-19 Alpha Lam <hclam@chromium.org> + + [chromium] Unreviewed. Build fix. + + Not building WebImageTest.cpp for component build. + + * WebKit.gyp: + +2012-09-19 Alpha Lam <hclam@chromium.org> + + [chromium] WebImage should use ImageDecoder directly + https://bugs.webkit.org/show_bug.cgi?id=96135 + + Reviewed by Adam Barth. + + This patch is for preparation of deferred image decoding. + ImageSource will be used as a portal to access deferred image decoder + by BitmapImage, it should not be accessible through WebKit APIs. + + WebImage now calls ImageDecoder directly which is the actual + implementation of an image decoder. + + Tests: WebImageTest.PNGImage + WebImageTest.ICOImage + WebImageTest.BadImage + + * WebKit.gypi: + * src/WebImageSkia.cpp: + (WebKit::WebImage::fromData): + (WebKit::WebImage::framesFromData): + * tests/WebImageTest.cpp: Added. + (WebKit): + (WebKit::readFile): + (WebKit::TEST): + * tests/data/black-and-white.ico: Added. + * tests/data/white-1x1.png: Added. + +2012-09-19 Oli Lan <olilan@chromium.org> + + [chromium] Add a method didHandleGestureEvent to WebViewClient, called from WebViewImpl::handleGestureEvent. + https://bugs.webkit.org/show_bug.cgi?id=96112 + + Reviewed by Adam Barth. + + Adds a new method didHandleGestureEvent to WebViewClient, called from WebViewImpl::handleGestureEvent. + + This will be used by the Android port to implement platform-specific gesture behaviour. + + This is tested by the new test WebViewTest.ClientTapHandlers. + + * public/WebViewClient.h: + (WebViewClient): + (WebKit::WebViewClient::didHandleGestureEvent): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::handleGestureEvent): + * tests/WebViewTest.cpp: + +2012-09-19 Robert Flack <flackr@chromium.org> + + [chromium] Support high DPI scroll bar on top level web frame. + https://bugs.webkit.org/show_bug.cgi?id=95134 + + Reviewed by Adrienne Walker. + + Calls setAppliesPageScale(true) on root scrollbar layers as these are not scaled. + + * src/NonCompositedContentHost.cpp: + (WebKit::setScrollbarBoundsContainPageScale): + (WebKit): + (WebKit::NonCompositedContentHost::setViewport): + +2012-09-19 Mark Pilgrim <pilgrim@chromium.org> + + [Chromium] Move notifyJSOutOfMemory out of PlatformSupport + https://bugs.webkit.org/show_bug.cgi?id=97116 + + Reviewed by Adam Barth. + + Part of a refactoring series. See tracking bug 82948. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::didExhaustMemoryAvailableForScript): + (WebKit): + * src/FrameLoaderClientImpl.h: + (FrameLoaderClientImpl): + * src/PlatformSupport.cpp: + (WebCore): + +2012-09-19 Mark Pilgrim <pilgrim@chromium.org> + + [Chromium] Remove unused popupsAllowed function from PlatformSupport + https://bugs.webkit.org/show_bug.cgi?id=96521 + + Reviewed by Eric Seidel. + + Part of a refactoring series. See tracking bug 82948. + + * src/PlatformSupport.cpp: + (WebCore): + +2012-09-19 Kent Tamura <tkent@chromium.org> + + [Chromium] Fix crash in WebFrameImpl::loadHistoryItem + https://bugs.webkit.org/show_bug.cgi?id=96352 + + Reviewed by Adam Barth. + + We have some crash reports with the following stack: + - HistoryItem::shouldDoSameDocumentNavigationTo. + - WebFrameImpl::loadHistoryItem + ... + + We don't have reproducible steps, and not sure what's the root + cause. Anyway we should check nullness of currentItem because + HistoryController::m_currentItem can be 0. + + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::loadHistoryItem): + Check nullness of currentItem. + +2012-09-18 Sailesh Agrawal <sail@chromium.org> + + Chromium: Scrollbar with tickmarks doesn't respond to clicks + https://bugs.webkit.org/show_bug.cgi?id=96049 + + Reviewed by Beth Dakin. + + Pipe isAlphaLocked and setIsAlphaLocked. + + * src/WebPluginScrollbarImpl.cpp: + (WebKit::WebPluginScrollbarImpl::isAlphaLocked): + (WebKit): + (WebKit::WebPluginScrollbarImpl::setIsAlphaLocked): + * src/WebPluginScrollbarImpl.h: + (WebPluginScrollbarImpl): + * src/WebScrollbarThemeClientImpl.cpp: + (WebKit::WebScrollbarThemeClientImpl::isAlphaLocked): + (WebKit): + (WebKit::WebScrollbarThemeClientImpl::setIsAlphaLocked): + * src/WebScrollbarThemeClientImpl.h: + (WebScrollbarThemeClientImpl): + * tests/ScrollbarLayerChromiumTest.cpp: + +2012-09-18 Alpha Lam <hclam@chromium.org> + + Unreviewed, rolling out r128939. + http://trac.webkit.org/changeset/128939 + https://bugs.webkit.org/show_bug.cgi?id=96135 + + Failing test_shell_tests. + + * WebKit.gypi: + * src/WebImageSkia.cpp: + (WebKit::WebImage::fromData): + (WebKit::WebImage::framesFromData): + * tests/WebImageTest.cpp: Removed. + * tests/data/black-and-white.ico: Removed. + * tests/data/white-1x1.png: Removed. + +2012-09-18 Alpha Lam <hclam@chromium.org> + + [chromium] WebImage should use ImageDecoder directly + https://bugs.webkit.org/show_bug.cgi?id=96135 + + Reviewed by Adam Barth. + + This patch is for preparation of deferred image decoding. + ImageSource will be used as a portal to access deferred image decoder + by BitmapImage, it should not be accessible through WebKit APIs. + + WebImage now calls ImageDecoder directly which is the actual + implementation of an image decoder. + + Tests: WebImageTest.PNGImage + WebImageTest.ICOImage + + * WebKit.gypi: + * src/WebImageSkia.cpp: + (WebKit::WebImage::fromData): + (WebKit::WebImage::framesFromData): + * tests/WebImageTest.cpp: Added. + (WebKit): + (WebKit::readFile): + (WebKit::TEST): + * tests/data/black-and-white.ico: Added. + * tests/data/white-1x1.png: Added. + +2012-09-18 Tommy Widenflycht <tommyw@google.com> + + MediaStream API: Create a flag to enable PeerConnection00 + https://bugs.webkit.org/show_bug.cgi?id=96989 + + Reviewed by Adam Barth. + + Adding the functionality to separately enable/disable PeerConnection00. + For now it is enabled by default. + + * public/WebRuntimeFeatures.h: + (WebRuntimeFeatures): + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableDeprecatedPeerConnection): + (WebKit): + (WebKit::WebRuntimeFeatures::isDeprecatedPeerConnectionEnabled): + +2012-09-18 Iain Merrick <husky@google.com> + + [Chromium] Merge moveSelectionStart, moveSelectionEnd, and moveCaret into selectRange + https://bugs.webkit.org/show_bug.cgi?id=96508 + + Reviewed by Ryosuke Niwa. + + These methods had "start" and "end" parameters, but this is incorrect. + selectRange() actually takes base and extent (where the user actually + touched), and selectionBounds() returns anchor and focus (base and extent + expanded to account for the selection granularity). + + This patch fixes the parameter names, and updates selectRange, its test + and its documentation to reflect the correct usage. It also removes + moveSelectionStart/moveSelectionEnd/moveCaret (which aren't being used + yet), and updates WebFrameTest to show how these can be implemented via + selectRange. + + * public/WebFrame.h: + (WebFrame): + * public/WebWidget.h: + (WebWidget): + (WebKit::WebWidget::selectionBounds): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::selectRange): + * src/WebFrameImpl.h: + (WebFrameImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::selectionBounds): + * src/WebViewImpl.h: + (WebViewImpl): + * tests/WebFrameTest.cpp: + +2012-09-18 Terry Anderson <tdanderson@chromium.org> + + Roll chromium DEPS to r157342 + https://bugs.webkit.org/show_bug.cgi?id=96963 + + Reviewed by Stephen White. + + Roll chromium DEPS to r157342. Also include the top-level directory + google_apis as a dependency, which was required for r157130. + + * DEPS: + 2012-09-17 Brian Anderson <brianderson@chromium.org> [chromium] Add rendering commit statistics diff --git a/Source/WebKit/chromium/DEPS b/Source/WebKit/chromium/DEPS index c5ab4a936..77a0b0dfe 100644 --- a/Source/WebKit/chromium/DEPS +++ b/Source/WebKit/chromium/DEPS @@ -32,7 +32,7 @@ vars = { 'chromium_svn': 'http://src.chromium.org/svn/trunk/src', - 'chromium_rev': '157063' + 'chromium_rev': '157342' } deps = { @@ -91,6 +91,8 @@ deps = { 'cc': Var('chromium_svn')+'/cc@'+Var('chromium_rev'), + 'google_apis': + Var('chromium_svn')+'/google_apis@' + Var('chromium_rev'), 'gpu': Var('chromium_svn')+'/gpu@'+Var('chromium_rev'), 'ipc': diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index 179ad50ef..59ab2492d 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -720,6 +720,7 @@ 'tests/RenderTableRowTest.cpp', 'tests/URLTestHelpers.cpp', 'tests/WebFrameTest.cpp', + 'tests/WebImageTest.cpp', 'tests/WebPageNewSerializerTest.cpp', 'tests/WebPageSerializerTest.cpp', 'tests/WebViewTest.cpp', diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi index edebf1b3c..b16a6018a 100644 --- a/Source/WebKit/chromium/WebKit.gypi +++ b/Source/WebKit/chromium/WebKit.gypi @@ -103,6 +103,7 @@ 'tests/WebCompositorInputHandlerImplTest.cpp', 'tests/WebFrameTest.cpp', 'tests/WebInputEventConversionTest.cpp', + 'tests/WebImageTest.cpp', 'tests/WebMediaPlayerClientImplTest.cpp', 'tests/WebPageNewSerializerTest.cpp', 'tests/WebPageSerializerTest.cpp', diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi index c51035d71..5b51e5391 100644 --- a/Source/WebKit/chromium/features.gypi +++ b/Source/WebKit/chromium/features.gypi @@ -77,7 +77,7 @@ 'ENABLE_JAVASCRIPT_DEBUGGER=1', 'ENABLE_LEGACY_CSS_VENDOR_PREFIXES=0', 'ENABLE_LEGACY_VIEWPORT_ADAPTION=1', - 'ENABLE_LEGACY_VENDOR_PREFIXES=1', + 'ENABLE_LEGACY_VENDOR_PREFIXES=0', 'ENABLE_LEGACY_WEBKIT_BLOB_BUILDER=1', 'ENABLE_LINK_PREFETCH=1', 'ENABLE_LINK_PRERENDER=1', @@ -119,6 +119,7 @@ 'ENABLE_WORKERS=1', 'ENABLE_XHR_RESPONSE_BLOB=1', 'ENABLE_XSLT=1', + 'SK_SUPPORT_HINTING_SCALE_FACTOR', 'WTF_USE_LEVELDB=1', 'WTF_USE_BUILTIN_UTF8_CODEC=1', # WTF_USE_DYNAMIC_ANNOTATIONS=1 may be defined in build/common.gypi diff --git a/Source/WebKit/chromium/public/WebFrame.h b/Source/WebKit/chromium/public/WebFrame.h index 56cbe1ea4..f38c73934 100644 --- a/Source/WebKit/chromium/public/WebFrame.h +++ b/Source/WebKit/chromium/public/WebFrame.h @@ -472,30 +472,12 @@ public: // there is ranged selection. virtual bool selectWordAroundCaret() = 0; - // DEPRECATED: Use moveSelectionStart / moveSelectionEnd / moveCaret - // This method is intended for touch-based UIs, but it's missing some - // functionality needed on Android, like preventing collapsed selections. - virtual void selectRange(const WebPoint& start, const WebPoint& end) = 0; + // Select a range of text, as if by drag-selecting from base to extent + // with character granularity. + virtual void selectRange(const WebPoint& base, const WebPoint& extent) = 0; virtual void selectRange(const WebRange&) = 0; - // The methods below are for adjusting the start and/or end of the current - // selection by direct manipulation on a touch-based UI. To enter selection - // mode in the first place, call selectRange() or send a fake mouse event. - - // Moves the start of the current selection, keeping the end fixed. - // Returns true on success, false if there is no selection to modify. - virtual bool moveSelectionStart(const WebPoint&, bool allowCollapsedSelection) = 0; - - // Moves the end of the current selection, keeping the start fixed. - // Returns true on success, false if there is no selection to modify. - virtual bool moveSelectionEnd(const WebPoint&, bool allowCollapsedSelection) = 0; - - // Move both endpoints of the current selection to the given position. - // The caret will remain pinned inside the current editable region. - // Returns true on success, false if there is no selection or if we're not editing. - virtual bool moveCaret(const WebPoint&) = 0; - // Printing ------------------------------------------------------------ // Reformats the WebFrame for printing. WebPrintParams specifies the printable diff --git a/Source/WebKit/chromium/public/WebRuntimeFeatures.h b/Source/WebKit/chromium/public/WebRuntimeFeatures.h index 012efe82d..6d0629fea 100644 --- a/Source/WebKit/chromium/public/WebRuntimeFeatures.h +++ b/Source/WebKit/chromium/public/WebRuntimeFeatures.h @@ -112,6 +112,8 @@ public: WEBKIT_EXPORT static void enablePeerConnection(bool); WEBKIT_EXPORT static bool isPeerConnectionEnabled(); + WEBKIT_EXPORT static void enableDeprecatedPeerConnection(bool); + WEBKIT_EXPORT static bool isDeprecatedPeerConnectionEnabled(); WEBKIT_EXPORT static void enableFullScreenAPI(bool); WEBKIT_EXPORT static bool isFullScreenAPIEnabled(); diff --git a/Source/WebKit/chromium/public/WebViewClient.h b/Source/WebKit/chromium/public/WebViewClient.h index 839ed0d17..88da1416b 100644 --- a/Source/WebKit/chromium/public/WebViewClient.h +++ b/Source/WebKit/chromium/public/WebViewClient.h @@ -142,6 +142,9 @@ public: // Called to retrieve the provider of desktop notifications. virtual WebNotificationPresenter* notificationPresenter() { return 0; } + // Called when a gesture event is handled. + virtual void didHandleGestureEvent(const WebGestureEvent& event, bool eventSwallowed) { } + // Called to request an icon for the specified filenames. // The icon is shown in a file upload control. virtual bool queryIconForFiles(const WebVector<WebString>& filenames, WebIconLoadingCompletion*) { return false; } diff --git a/Source/WebKit/chromium/public/WebWidget.h b/Source/WebKit/chromium/public/WebWidget.h index ac1658140..fa456238a 100644 --- a/Source/WebKit/chromium/public/WebWidget.h +++ b/Source/WebKit/chromium/public/WebWidget.h @@ -194,9 +194,9 @@ public: // FIXME: Remove this method. It's redundant with textInputInfo(). virtual WebTextInputType textInputType() { return WebTextInputTypeNone; } - // Returns the start and end bounds of the current selection. + // Returns the anchor and focus bounds of the current selection. // If the selection range is empty, it returns the caret bounds. - virtual bool selectionBounds(WebRect& start, WebRect& end) const { return false; } + virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const { return false; } // Returns the text direction at the start and end bounds of the current selection. // If the selection range is empty, it returns false. diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp index 5dd02b563..7a616c520 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp @@ -142,6 +142,12 @@ void FrameLoaderClientImpl::documentElementAvailable() m_webFrame->client()->didCreateDocumentElement(m_webFrame); } +void FrameLoaderClientImpl::didExhaustMemoryAvailableForScript() +{ + if (m_webFrame->client()) + m_webFrame->client()->didExhaustMemoryAvailableForScript(m_webFrame); +} + #if USE(V8) void FrameLoaderClientImpl::didCreateScriptContext(v8::Handle<v8::Context> context, int extensionGroup, int worldId) { diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h index ecb20a2fb..1cf5cd1e1 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h @@ -61,6 +61,9 @@ public: virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); virtual void documentElementAvailable(); + // Script in the page tried to allocate too much memory. + virtual void didExhaustMemoryAvailableForScript(); + #if USE(V8) virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId); virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId); diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp index ae99ba889..9729d05ec 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp @@ -88,6 +88,20 @@ void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer) ASSERT(haveScrollLayer()); } +static void setScrollbarBoundsContainPageScale(WebCore::GraphicsLayer* layer, WebCore::GraphicsLayer* clipLayer) +{ + // Scrollbars are attached outside the root clip rect, so skip the + // clipLayer subtree. + if (layer == clipLayer) + return; + + for (size_t i = 0; i < layer->children().size(); ++i) + setScrollbarBoundsContainPageScale(layer->children()[i], clipLayer); + + if (layer->children().isEmpty()) + layer->setAppliesPageScale(true); +} + void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin) { if (!haveScrollLayer()) @@ -119,6 +133,12 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, m_graphicsLayer->setNeedsDisplay(); } else if (visibleRectChanged) m_graphicsLayer->setNeedsDisplay(); + + WebCore::GraphicsLayer* clipLayer = m_graphicsLayer->parent()->parent(); + WebCore::GraphicsLayer* rootLayer = clipLayer; + while (rootLayer->parent()) + rootLayer = rootLayer->parent(); + setScrollbarBoundsContainPageScale(rootLayer, clipLayer); } bool NonCompositedContentHost::haveScrollLayer() diff --git a/Source/WebKit/chromium/src/PlatformSupport.cpp b/Source/WebKit/chromium/src/PlatformSupport.cpp index 762055497..2fb6f1059 100644 --- a/Source/WebKit/chromium/src/PlatformSupport.cpp +++ b/Source/WebKit/chromium/src/PlatformSupport.cpp @@ -499,17 +499,6 @@ void PlatformSupport::paintThemePart( // Glue layer. Once the Glue layer moves entirely into the WebKit layer, these // methods will be deleted. -void PlatformSupport::notifyJSOutOfMemory(Frame* frame) -{ - if (!frame) - return; - - WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); - if (!webFrame->client()) - return; - webFrame->client()->didExhaustMemoryAvailableForScript(webFrame); -} - int PlatformSupport::screenHorizontalDPI(Widget* widget) { WebWidgetClient* client = toWebWidgetClient(widget); @@ -566,12 +555,6 @@ IntRect PlatformSupport::screenAvailableRect(Widget* widget) return client->screenInfo().availableRect; } -bool PlatformSupport::popupsAllowed(NPP npp) -{ - // FIXME: Give the embedder a way to control this. - return false; -} - #if ENABLE(WORKERS) WorkerContextProxy* WorkerContextProxy::create(Worker* worker) { diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index 7bb0efeea..6d68a6f23 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -1029,7 +1029,7 @@ void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) m_frame->loader()->prepareForHistoryNavigation(); RefPtr<HistoryItem> currentItem = m_frame->loader()->history()->currentItem(); - m_inSameDocumentHistoryLoad = currentItem->shouldDoSameDocumentNavigationTo(historyItem.get()); + m_inSameDocumentHistoryLoad = currentItem && currentItem->shouldDoSameDocumentNavigationTo(historyItem.get()); m_frame->page()->goToItem(historyItem.get(), FrameLoadTypeIndexedBackForward); m_inSameDocumentHistoryLoad = false; @@ -1466,71 +1466,15 @@ bool WebFrameImpl::selectWordAroundCaret() return true; } -void WebFrameImpl::selectRange(const WebPoint& start, const WebPoint& end) +void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) { - if (start == end && moveCaret(start)) - return; - - if (moveSelectionStart(start, true) && moveSelectionEnd(end, true)) - return; - - // Failed to move endpoints, probably because there's no current selection. - // Just set the selection explicitly (but this won't handle editable boundaries correctly). - VisibleSelection newSelection(visiblePositionForWindowPoint(start), visiblePositionForWindowPoint(end)); + VisiblePosition basePos = visiblePositionForWindowPoint(base); + VisiblePosition extentPos = visiblePositionForWindowPoint(extent); + VisibleSelection newSelection = VisibleSelection(basePos, extentPos); if (frame()->selection()->shouldChangeSelection(newSelection)) frame()->selection()->setSelection(newSelection, CharacterGranularity); } -bool WebFrameImpl::moveSelectionStart(const WebPoint& point, bool allowCollapsedSelection) -{ - const VisibleSelection& selection = frame()->selection()->selection(); - if (selection.isNone()) - return false; - - VisiblePosition start = visiblePositionForWindowPoint(point); - if (!allowCollapsedSelection) { - VisiblePosition maxStart = selection.visibleEnd().previous(); - if (comparePositions(start, maxStart) > 0) - start = maxStart; - } - - // start is moving, so base=end, extent=start - VisibleSelection newSelection = VisibleSelection(selection.visibleEnd(), start); - frame()->selection()->setNonDirectionalSelectionIfNeeded(newSelection, CharacterGranularity); - return true; -} - -bool WebFrameImpl::moveSelectionEnd(const WebPoint& point, bool allowCollapsedSelection) -{ - const VisibleSelection& selection = frame()->selection()->selection(); - if (selection.isNone()) - return false; - - VisiblePosition end = visiblePositionForWindowPoint(point); - if (!allowCollapsedSelection) { - VisiblePosition minEnd = selection.visibleStart().next(); - if (comparePositions(end, minEnd) < 0) - end = minEnd; - } - - // end is moving, so base=start, extent=end - VisibleSelection newSelection = VisibleSelection(selection.visibleStart(), end); - frame()->selection()->setNonDirectionalSelectionIfNeeded(newSelection, CharacterGranularity); - return true; -} - -bool WebFrameImpl::moveCaret(const WebPoint& point) -{ - FrameSelection* frameSelection = frame()->selection(); - if (frameSelection->isNone() || !frameSelection->isContentEditable()) - return false; - - VisiblePosition pos = visiblePositionForWindowPoint(point); - frameSelection->setExtent(pos, UserTriggered); - frameSelection->setBase(frameSelection->extent(), UserTriggered); - return true; -} - void WebFrameImpl::selectRange(const WebRange& webRange) { RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange); diff --git a/Source/WebKit/chromium/src/WebFrameImpl.h b/Source/WebKit/chromium/src/WebFrameImpl.h index 58525d701..a2fe797e3 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.h +++ b/Source/WebKit/chromium/src/WebFrameImpl.h @@ -184,11 +184,8 @@ public: virtual WebString selectionAsText() const; virtual WebString selectionAsMarkup() const; virtual bool selectWordAroundCaret(); - virtual void selectRange(const WebPoint& start, const WebPoint& end); + virtual void selectRange(const WebPoint& base, const WebPoint& extent); virtual void selectRange(const WebRange&); - virtual bool moveSelectionStart(const WebPoint&, bool allowCollapsedSelection); - virtual bool moveSelectionEnd(const WebPoint&, bool allowCollapsedSelection); - virtual bool moveCaret(const WebPoint&); virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode, bool* useBrowserOverlays); diff --git a/Source/WebKit/chromium/src/WebImageSkia.cpp b/Source/WebKit/chromium/src/WebImageSkia.cpp index e1a926050..0198a6806 100644 --- a/Source/WebKit/chromium/src/WebImageSkia.cpp +++ b/Source/WebKit/chromium/src/WebImageSkia.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "Image.h" -#include "ImageSource.h" +#include "ImageDecoder.h" #include "NativeImageSkia.h" #include "SharedBuffer.h" @@ -51,19 +51,23 @@ namespace WebKit { WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) { - ImageSource source; - source.setData(PassRefPtr<SharedBuffer>(data).get(), true); - if (!source.isSizeAvailable()) + RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data); + OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied))); + if (!decoder) + return WebImage(); + + decoder->setData(buffer.get(), true); + if (!decoder->isSizeAvailable()) return WebImage(); // Frames are arranged by decreasing size, then decreasing bit depth. // Pick the frame closest to |desiredSize|'s area without being smaller, // which has the highest bit depth. - const size_t frameCount = source.frameCount(); + const size_t frameCount = decoder->frameCount(); size_t index = 0; // Default to first frame if none are large enough. int frameAreaAtIndex = 0; for (size_t i = 0; i < frameCount; ++i) { - const IntSize frameSize = source.frameSizeAtIndex(i); + const IntSize frameSize = decoder->frameSizeAtIndex(i); if (WebSize(frameSize) == desiredSize) { index = i; break; // Perfect match. @@ -79,11 +83,15 @@ WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) } } - OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(index)); + ImageFrame* frame = decoder->frameBufferAtIndex(index); if (!frame) return WebImage(); - return WebImage(frame->bitmap()); + OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage()); + if (!image) + return WebImage(); + + return WebImage(image->bitmap()); } WebVector<WebImage> WebImage::framesFromData(const WebData& data) @@ -91,26 +99,34 @@ WebVector<WebImage> WebImage::framesFromData(const WebData& data) // This is to protect from malicious images. It should be big enough that it's never hit in pracice. const size_t maxFrameCount = 8; - ImageSource source; - source.setData(PassRefPtr<SharedBuffer>(data).get(), true); - if (!source.isSizeAvailable()) + RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data); + OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied))); + if (!decoder) + return WebVector<WebImage>(); + + decoder->setData(buffer.get(), true); + if (!decoder->isSizeAvailable()) return WebVector<WebImage>(); // Frames are arranged by decreasing size, then decreasing bit depth. // Keep the first frame at every size, has the highest bit depth. - const size_t frameCount = source.frameCount(); + const size_t frameCount = decoder->frameCount(); IntSize lastSize; Vector<WebImage> frames; for (size_t i = 0; i < std::min(frameCount, maxFrameCount); ++i) { - const IntSize frameSize = source.frameSizeAtIndex(i); + const IntSize frameSize = decoder->frameSizeAtIndex(i); if (frameSize == lastSize) continue; lastSize = frameSize; - OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(i)); - if (frame) - frames.append(WebImage(frame->bitmap())); + ImageFrame* frame = decoder->frameBufferAtIndex(i); + if (!frame) + continue; + + OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage()); + if (image.get()) + frames.append(WebImage(image->bitmap())); } return frames; diff --git a/Source/WebKit/chromium/src/WebPluginScrollbarImpl.cpp b/Source/WebKit/chromium/src/WebPluginScrollbarImpl.cpp index f34dbfdc7..b993a1348 100644 --- a/Source/WebKit/chromium/src/WebPluginScrollbarImpl.cpp +++ b/Source/WebKit/chromium/src/WebPluginScrollbarImpl.cpp @@ -268,6 +268,16 @@ bool WebPluginScrollbarImpl::handleInputEvent(const WebInputEvent& event) return false; } +bool WebPluginScrollbarImpl::isAlphaLocked() const +{ + return m_scrollbar->isAlphaLocked(); +} + +void WebPluginScrollbarImpl::setIsAlphaLocked(bool flag) +{ + return m_scrollbar->setIsAlphaLocked(flag); +} + bool WebPluginScrollbarImpl::onMouseDown(const WebInputEvent& event) { WebMouseEvent mousedown = *static_cast<const WebMouseEvent*>(&event); diff --git a/Source/WebKit/chromium/src/WebPluginScrollbarImpl.h b/Source/WebKit/chromium/src/WebPluginScrollbarImpl.h index 43e3fd7b2..90ba94172 100644 --- a/Source/WebKit/chromium/src/WebPluginScrollbarImpl.h +++ b/Source/WebKit/chromium/src/WebPluginScrollbarImpl.h @@ -82,6 +82,8 @@ public: virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier) OVERRIDE; virtual void paint(WebCanvas*, const WebRect&) OVERRIDE; virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE; + virtual bool isAlphaLocked() const OVERRIDE; + virtual void setIsAlphaLocked(bool) OVERRIDE; private: bool onMouseDown(const WebInputEvent&); diff --git a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp index bbd71bc82..bcdba86c1 100644 --- a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -368,6 +368,24 @@ bool WebRuntimeFeatures::isPeerConnectionEnabled() #endif } +void WebRuntimeFeatures::enableDeprecatedPeerConnection(bool enable) +{ +#if ENABLE(MEDIA_STREAM) + RuntimeEnabledFeatures::setDeprecatedPeerConnectionEnabled(enable); +#else + UNUSED_PARAM(enable); +#endif +} + +bool WebRuntimeFeatures::isDeprecatedPeerConnectionEnabled() +{ +#if ENABLE(MEDIA_STREAM) + return RuntimeEnabledFeatures::deprecatedPeerConnectionEnabled(); +#else + return false; +#endif +} + void WebRuntimeFeatures::enableFullScreenAPI(bool enable) { #if ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.cpp b/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.cpp index 68c9458d0..f160e5776 100644 --- a/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.cpp @@ -218,4 +218,14 @@ bool WebScrollbarThemeClientImpl::isOverlayScrollbar() const return m_scrollbar->isOverlay(); } +bool WebScrollbarThemeClientImpl::isAlphaLocked() const +{ + return m_scrollbar->isAlphaLocked(); +} + +void WebScrollbarThemeClientImpl::setIsAlphaLocked(bool flag) +{ + m_scrollbar->setIsAlphaLocked(flag); +} + } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.h b/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.h index b3a6ac956..48f967177 100644 --- a/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.h +++ b/Source/WebKit/chromium/src/WebScrollbarThemeClientImpl.h @@ -78,6 +78,8 @@ public: virtual bool enabled() const OVERRIDE; virtual void setEnabled(bool) OVERRIDE; virtual bool isOverlayScrollbar() const OVERRIDE; + virtual bool isAlphaLocked() const OVERRIDE; + virtual void setIsAlphaLocked(bool) OVERRIDE; private: WebKit::WebScrollbar* m_scrollbar; diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index 97416e024..764ae6dca 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -682,6 +682,7 @@ void WebViewImpl::scrollBy(const WebCore::IntPoint& delta) #if ENABLE(GESTURE_EVENTS) bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) { + bool eventSwallowed = false; switch (event.type) { case WebInputEvent::GestureFlingStart: { m_client->cancelScheduledContentIntents(); @@ -692,18 +693,21 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) OwnPtr<PlatformGestureCurve> flingCurve = PlatformGestureCurveFactory::get()->createCurve(event.data.flingStart.sourceDevice, FloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY)); m_gestureAnimation = ActivePlatformGestureAnimation::create(flingCurve.release(), this); scheduleAnimation(); - return true; + eventSwallowed = true; + break; } case WebInputEvent::GestureFlingCancel: if (m_gestureAnimation) { m_gestureAnimation.clear(); - return true; + eventSwallowed = true; } - return false; + break; case WebInputEvent::GestureTap: { m_client->cancelScheduledContentIntents(); - if (detectContentOnTouch(WebPoint(event.x, event.y), event.type)) - return true; + if (detectContentOnTouch(WebPoint(event.x, event.y), event.type)) { + eventSwallowed = true; + break; + } RefPtr<WebCore::PopupContainer> selectPopup; selectPopup = m_selectPopup; @@ -716,12 +720,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), pageScaleFactor(), goodTargets); // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101 - if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(event, goodTargets)) - return true; + if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(event, goodTargets)) { + eventSwallowed = true; + break; + } } PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); - bool gestureHandled = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); + eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); if (m_selectPopup && m_selectPopup == selectPopup) { // That tap triggered a select popup which is the same as the one that @@ -731,23 +737,26 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) hideSelectPopup(); } - return gestureHandled; + break; } case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: { if (!mainFrameImpl() || !mainFrameImpl()->frameView()) - return false; + break; m_client->cancelScheduledContentIntents(); - if (detectContentOnTouch(WebPoint(event.x, event.y), event.type)) - return true; + if (detectContentOnTouch(WebPoint(event.x, event.y), event.type)) { + eventSwallowed = true; + break; + } m_page->contextMenuController()->clearContextMenu(); m_contextMenuAllowed = true; PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); - bool handled = mainFrameImpl()->frame()->eventHandler()->sendContextMenuEventForGesture(platformEvent); + eventSwallowed = mainFrameImpl()->frame()->eventHandler()->sendContextMenuEventForGesture(platformEvent); m_contextMenuAllowed = false; - return handled; + + break; } case WebInputEvent::GestureTapDown: { m_client->cancelScheduledContentIntents(); @@ -757,7 +766,8 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) enableTouchHighlight(IntPoint(event.x, event.y)); #endif PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); - return mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); + eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); + break; } case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureScrollBegin: @@ -769,12 +779,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) case WebInputEvent::GesturePinchEnd: case WebInputEvent::GesturePinchUpdate: { PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); - return mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); + eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); + break; } default: ASSERT_NOT_REACHED(); } - return false; + m_client->didHandleGestureEvent(event, eventSwallowed); + return eventSwallowed; } void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters& parameters) @@ -2223,7 +2235,7 @@ WebTextInputType WebViewImpl::textInputType() return WebTextInputTypeNone; } -bool WebViewImpl::selectionBounds(WebRect& start, WebRect& end) const +bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const { const Frame* frame = focusedWebCoreFrame(); if (!frame) @@ -2233,7 +2245,7 @@ bool WebViewImpl::selectionBounds(WebRect& start, WebRect& end) const return false; if (selection->isCaret()) { - start = end = frame->view()->contentsToWindow(selection->absoluteCaretBounds()); + anchor = focus = frame->view()->contentsToWindow(selection->absoluteCaretBounds()); return true; } @@ -2246,20 +2258,20 @@ bool WebViewImpl::selectionBounds(WebRect& start, WebRect& end) const selectedRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffset())); - start = frame->editor()->firstRectForRange(range.get()); + anchor = frame->editor()->firstRectForRange(range.get()); range = Range::create(selectedRange->endContainer()->document(), selectedRange->endContainer(), selectedRange->endOffset(), selectedRange->endContainer(), selectedRange->endOffset()); - end = frame->editor()->firstRectForRange(range.get()); + focus = frame->editor()->firstRectForRange(range.get()); - start = frame->view()->contentsToWindow(start); - end = frame->view()->contentsToWindow(end); + anchor = frame->view()->contentsToWindow(anchor); + focus = frame->view()->contentsToWindow(focus); if (!frame->selection()->selection().isBaseFirst()) - std::swap(start, end); + std::swap(anchor, focus); return true; } diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index 11a05d0de..865898608 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -167,7 +167,7 @@ public: virtual void extendSelectionAndDelete(int before, int after); virtual bool isSelectionEditable() const; virtual WebColor backgroundColor() const; - virtual bool selectionBounds(WebRect& start, WebRect& end) const; + virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const; virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const; virtual bool caretOrSelectionRange(size_t* location, size_t* length); virtual void setTextDirection(WebTextDirection direction); diff --git a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp index cb94243d0..6770bfe8a 100644 --- a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp +++ b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp @@ -113,7 +113,7 @@ private: FakeIDBDatabaseCallbacks() { } }; -TEST(IDBDatabaseBackendTest, ConnectionLifecycle) +TEST(IDBDatabaseBackendTest, DISABLED_ConnectionLifecycle) { RefPtr<IDBFakeBackingStore> backingStore = adoptRef(new IDBFakeBackingStore()); EXPECT_TRUE(backingStore->hasOneRef()); @@ -172,7 +172,7 @@ private: WebIDBDatabaseImpl& m_webDatabase; }; -TEST(IDBDatabaseBackendTest, ForcedClose) +TEST(IDBDatabaseBackendTest, DISABLED_ForcedClose) { RefPtr<IDBFakeBackingStore> backingStore = adoptRef(new IDBFakeBackingStore()); EXPECT_TRUE(backingStore->hasOneRef()); diff --git a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h index e0a5a8fa5..457ae3745 100644 --- a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h +++ b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h @@ -35,38 +35,38 @@ public: virtual void getDatabaseNames(Vector<String>& foundNames) OVERRIDE { } virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundIntVersion, int64_t& foundId) OVERRIDE { return false; } virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) OVERRIDE { return true; } - virtual bool updateIDBDatabaseMetaData(int64_t rowId, const String& version) OVERRIDE { return false; } - virtual bool updateIDBDatabaseIntVersion(int64_t rowId, int64_t version) OVERRIDE { return false; } + virtual bool updateIDBDatabaseMetaData(Transaction*, int64_t rowId, const String& version) OVERRIDE { return false; } + virtual bool updateIDBDatabaseIntVersion(Transaction*, int64_t rowId, int64_t version) OVERRIDE { return false; } virtual bool deleteDatabase(const String& name) OVERRIDE { return false; } virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) OVERRIDE { } - virtual bool createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) OVERRIDE { return false; } - virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId) OVERRIDE { } + virtual bool createObjectStore(Transaction*, int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) OVERRIDE { return false; } + virtual void deleteObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { } virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() OVERRIDE { return PassRefPtr<ObjectStoreRecordIdentifier>(); } - virtual String getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&) OVERRIDE { return String(); } - virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) OVERRIDE { return false; } - virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId) OVERRIDE { } - virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) OVERRIDE { } - virtual int64_t getKeyGeneratorCurrentNumber(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0; } - virtual bool maybeUpdateKeyGeneratorCurrentNumber(int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { return false; } - virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; } + virtual String getObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&) OVERRIDE { return String(); } + virtual bool putObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) OVERRIDE { return false; } + virtual void clearObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { } + virtual void deleteObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) OVERRIDE { } + virtual int64_t getKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0; } + virtual bool maybeUpdateKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { return false; } + virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; } - virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; } + virtual bool forEachObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; } virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) OVERRIDE { } - virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) OVERRIDE { return false; } - virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { } - virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } - virtual bool deleteIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } - virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return PassRefPtr<IDBKey>(); } - virtual bool keyExistsInIndex(int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) OVERRIDE { return false; } + virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) OVERRIDE { return false; } + virtual void deleteIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { } + virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } + virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } + virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return PassRefPtr<IDBKey>(); } + virtual bool keyExistsInIndex(Transaction*, int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) OVERRIDE { return false; } - virtual PassRefPtr<Cursor> openObjectStoreKeyCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } - virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } - virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } - virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } + virtual PassRefPtr<Cursor> openObjectStoreKeyCursor(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } + virtual PassRefPtr<Cursor> openObjectStoreCursor(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } + virtual PassRefPtr<Cursor> openIndexKeyCursor(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } + virtual PassRefPtr<Cursor> openIndexCursor(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } virtual PassRefPtr<Transaction> createTransaction() OVERRIDE { return PassRefPtr<Transaction>(); } }; diff --git a/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp b/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp index 38b0c9885..0cf82494b 100644 --- a/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp +++ b/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp @@ -29,6 +29,7 @@ #include "Color.h" #include "GraphicsContext.h" #include "IntRect.h" +#include "PlatformContextSkia.h" #include "skia/ext/platform_canvas.h" #include <public/WebFloatRect.h> #include <public/WebRect.h> @@ -100,6 +101,22 @@ struct PaintFillPartialOpaque : public PaintCallback { IntRect m_opaqueRect; }; +#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR) +struct HintingScaleCallback : public PaintCallback { + HintingScaleCallback() + : hintingScale(SK_Scalar1) + { + } + + virtual void operator()(GraphicsContext& context, const IntRect& contentRect) + { + hintingScale = context.platformContext()->hintingScaleFactor(); + } + + SkScalar hintingScale; +}; +#endif + #define EXPECT_EQ_RECT(a, b) \ EXPECT_EQ(a.x, b.x); \ EXPECT_EQ(a.width, b.width); \ @@ -194,4 +211,23 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectTranslat EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect); } +#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR) +TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testHintingScaleFactorSet) +{ + HintingScaleCallback callback; + TestLayerPainterChromium painter(callback); + OpaqueRectTrackingContentLayerDelegate delegate(&painter); + + SkScalar hintingScale = SkIntToScalar(2); + SkCanvas canvas; + canvas.scale(hintingScale, hintingScale); + EXPECT_EQ(callback.hintingScale, SK_Scalar1); + + IntRect rectA; + WebFloatRect rectB; + delegate.paintContents(&canvas, rectA, rectB); + EXPECT_EQ(callback.hintingScale, hintingScale); +} +#endif + } // namespace diff --git a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp index eb2c07512..c73b6149a 100644 --- a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp +++ b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp @@ -830,4 +830,21 @@ TEST(PlatformContextSkiaTest, PreserveOpaqueOnlyMattersForFirstLayer) EXPECT_PIXELS_MATCH_EXACT(bitmap, platformContext.opaqueRegion().asRect()); } +#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR) +TEST(PlatformContextSkiaTest, hintingScaleFactorAppliedOnPaint) +{ + SkBitmap bitmap; + SkCanvas canvas(bitmap); + + SkScalar hintingScale = SkIntToScalar(2); + PlatformContextSkia platformContext(&canvas); + platformContext.setHintingScaleFactor(hintingScale); + + SkPaint paint; + EXPECT_EQ(paint.getHintingScaleFactor(), SK_Scalar1); + platformContext.setupPaintCommon(&paint); + EXPECT_EQ(paint.getHintingScaleFactor(), hintingScale); +} +#endif + } // namespace diff --git a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp index c6efbb5bf..b85149bcd 100644 --- a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp @@ -61,6 +61,8 @@ public: virtual ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE { return WebScrollbar::ScrollbarOverlayStyleDefault; } virtual bool isCustomScrollbar() const OVERRIDE { return false; } virtual Orientation orientation() const OVERRIDE { return WebScrollbar::Horizontal; } + virtual bool isAlphaLocked() const OVERRIDE { return false; } + virtual void setIsAlphaLocked(bool) OVERRIDE { } }; TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer) diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index 4328a0e4a..a0049b67e 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -1072,7 +1072,7 @@ TEST_F(WebFrameTest, SelectRange) frame = webView->mainFrame(); EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); webView->selectionBounds(startWebRect, endWebRect); - frame->selectRange(WebPoint(0, 0), bottomRightMinusOne(endWebRect)); + frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame)); webView->close(); @@ -1086,176 +1086,100 @@ TEST_F(WebFrameTest, SelectRange) webView->close(); } -TEST_F(WebFrameTest, MoveSelectionStart) +TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart) { registerMockedHttpURLLoad("text_selection.html"); WebView* webView = createWebViewForTextSelection(m_baseURL + "text_selection.html"); WebFrame* frame = webView->mainFrame(); - // moveSelectionStart() always returns false if there's no selection. - EXPECT_FALSE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), false)); - EXPECT_FALSE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), true)); - - frame->executeScript(WebScriptSource("selectElement('header_1');")); - EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "header_2")), false)); - EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); - // Select second span. We can move the start to include the first span. frame->executeScript(WebScriptSource("selectElement('header_2');")); EXPECT_EQ("Header 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), false)); + frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), topLeft(elementBounds(frame, "header_1"))); EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); - // If allowCollapsedSelection=false we can't move the selection start beyond the current end. - // We end up with a single character selected. + // We can move the start and end together. frame->executeScript(WebScriptSource("selectElement('header_1');")); EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(bottomRightMinusOne(elementBounds(frame, "header_1")), false)); - EXPECT_EQ(".", selectionAsString(frame)); - - // If allowCollapsedSelection=true we can move the start and end together. - frame->executeScript(WebScriptSource("selectElement('header_1');")); - EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(bottomRightMinusOne(elementBounds(frame, "header_1")), true)); + frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "header_1"))); EXPECT_EQ("", selectionAsString(frame)); // Selection is a caret, not empty. EXPECT_FALSE(frame->selectionRange().isNull()); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), true)); - EXPECT_EQ("Header 1.", selectionAsString(frame)); - // If allowCollapsedSelection=true we can move the start across the end. + // We can move the start across the end. frame->executeScript(WebScriptSource("selectElement('header_1');")); EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(bottomRightMinusOne(elementBounds(frame, "header_2")), true)); + frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "header_2"))); EXPECT_EQ(" Header 2.", selectionAsString(frame)); // Can't extend the selection part-way into an editable element. frame->executeScript(WebScriptSource("selectElement('footer_2');")); EXPECT_EQ("Footer 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "editable_2")), true)); + frame->selectRange(bottomRightMinusOne(elementBounds(frame, "footer_2")), topLeft(elementBounds(frame, "editable_2"))); EXPECT_EQ(" [ Footer 1. Footer 2.", selectionAsString(frame)); // Can extend the selection completely across editable elements. frame->executeScript(WebScriptSource("selectElement('footer_2');")); EXPECT_EQ("Footer 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_2")), true)); + frame->selectRange(bottomRightMinusOne(elementBounds(frame, "footer_2")), topLeft(elementBounds(frame, "header_2"))); EXPECT_EQ("Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1. Footer 2.", selectionAsString(frame)); // If the selection is editable text, we can't extend it into non-editable text. frame->executeScript(WebScriptSource("selectElement('editable_2');")); EXPECT_EQ("Editable 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_2")), true)); + frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")), topLeft(elementBounds(frame, "header_2"))); EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); webView->close(); } -TEST_F(WebFrameTest, MoveSelectionEnd) +TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd) { registerMockedHttpURLLoad("text_selection.html"); WebView* webView = createWebViewForTextSelection(m_baseURL + "text_selection.html"); WebFrame* frame = webView->mainFrame(); - // moveSelectionEnd() always returns false if there's no selection. - EXPECT_FALSE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_1")), false)); - EXPECT_FALSE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_1")), true)); - // Select first span. We can move the end to include the second span. frame->executeScript(WebScriptSource("selectElement('header_1');")); EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "header_2")), false)); + frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "header_2"))); EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); - // If allowCollapsedSelection=false we can't move the selection end beyond the current start. - // We end up with a single character selected. + // We can move the start and end together. frame->executeScript(WebScriptSource("selectElement('header_2');")); EXPECT_EQ("Header 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_2")), false)); - EXPECT_EQ("H", selectionAsString(frame)); - - // If allowCollapsedSelection=true we can move the start and end together. - frame->executeScript(WebScriptSource("selectElement('header_2');")); - EXPECT_EQ("Header 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_2")), true)); + frame->selectRange(topLeft(elementBounds(frame, "header_2")), topLeft(elementBounds(frame, "header_2"))); EXPECT_EQ("", selectionAsString(frame)); // Selection is a caret, not empty. EXPECT_FALSE(frame->selectionRange().isNull()); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "header_2")), true)); - EXPECT_EQ("Header 2.", selectionAsString(frame)); - // If allowCollapsedSelection=true we can move the end across the start. + // We can move the end across the start. frame->executeScript(WebScriptSource("selectElement('header_2');")); EXPECT_EQ("Header 2.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_1")), true)); + frame->selectRange(topLeft(elementBounds(frame, "header_2")), topLeft(elementBounds(frame, "header_1"))); EXPECT_EQ("Header 1. ", selectionAsString(frame)); // Can't extend the selection part-way into an editable element. frame->executeScript(WebScriptSource("selectElement('header_1');")); EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "editable_1")), true)); + frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "editable_1"))); EXPECT_EQ("Header 1. Header 2. ] ", selectionAsString(frame)); // Can extend the selection completely across editable elements. frame->executeScript(WebScriptSource("selectElement('header_1');")); EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "footer_1")), true)); + frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "footer_1"))); EXPECT_EQ("Header 1. Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1.", selectionAsString(frame)); // If the selection is editable text, we can't extend it into non-editable text. frame->executeScript(WebScriptSource("selectElement('editable_1');")); EXPECT_EQ("Editable 1.", selectionAsString(frame)); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "footer_1")), true)); + frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightMinusOne(elementBounds(frame, "footer_1"))); EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); webView->close(); } -TEST_F(WebFrameTest, MoveCaret) -{ - registerMockedHttpURLLoad("text_selection.html"); - WebView* webView = createWebViewForTextSelection(m_baseURL + "text_selection.html"); - WebFrame* frame = webView->mainFrame(); - - // moveCaret() returns false if there's no selection, or if it isn't editable. - EXPECT_FALSE(frame->moveCaret(topLeft(elementBounds(frame, "editable")))); - frame->executeScript(WebScriptSource("selectElement('header_1');")); - EXPECT_EQ("Header 1.", selectionAsString(frame)); - EXPECT_FALSE(frame->moveCaret(topLeft(elementBounds(frame, "editable")))); - - // Select the editable text span. Now moveCaret() works. - frame->executeScript(WebScriptSource("selectElement('editable_1');")); - EXPECT_EQ("Editable 1.", selectionAsString(frame)); - - EXPECT_TRUE(frame->moveCaret(topLeft(elementBounds(frame, "editable_1")))); - EXPECT_EQ("", selectionAsString(frame)); - EXPECT_FALSE(frame->selectionRange().isNull()); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "editable_1")), false)); - EXPECT_EQ("Editable 1.", selectionAsString(frame)); - - EXPECT_TRUE(frame->moveCaret(bottomRightMinusOne(elementBounds(frame, "editable_2")))); - EXPECT_EQ("", selectionAsString(frame)); - EXPECT_FALSE(frame->selectionRange().isNull()); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "editable_2")), false)); - EXPECT_EQ("Editable 2.", selectionAsString(frame)); - - // Caret is pinned at the start of the editable region. - EXPECT_TRUE(frame->moveCaret(topLeft(elementBounds(frame, "header_1")))); - EXPECT_EQ("", selectionAsString(frame)); - EXPECT_FALSE(frame->selectionRange().isNull()); - EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "editable_1")), false)); - EXPECT_EQ("[ Editable 1.", selectionAsString(frame)); - - // Caret is pinned at the end of the editable region. - EXPECT_TRUE(frame->moveCaret(bottomRightMinusOne(elementBounds(frame, "footer_2")))); - EXPECT_EQ("", selectionAsString(frame)); - EXPECT_FALSE(frame->selectionRange().isNull()); - EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "editable_2")), false)); - EXPECT_EQ("Editable 2. ]", selectionAsString(frame)); - - webView->close(); -} - class DisambiguationPopupTestWebViewClient : public WebViewClient { public: virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<WebRect>& targetRects) OVERRIDE diff --git a/Source/WebKit/chromium/tests/WebImageTest.cpp b/Source/WebKit/chromium/tests/WebImageTest.cpp new file mode 100644 index 000000000..f968176cf --- /dev/null +++ b/Source/WebKit/chromium/tests/WebImageTest.cpp @@ -0,0 +1,102 @@ +/* + * 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. + */ + +#include "config.h" + +#include <public/WebImage.h> + +#include "FileSystem.h" +#include "SharedBuffer.h" +#include <gtest/gtest.h> +#include <public/WebData.h> +#include <public/WebSize.h> +#include <webkit/support/webkit_support.h> + +using namespace WebCore; +using namespace WebKit; + +namespace { + +static PassRefPtr<SharedBuffer> readFile(const char* fileName) +{ + String filePath = webkit_support::GetWebKitRootDir(); + filePath.append("/Source/WebKit/chromium/tests/data/"); + filePath.append(fileName); + + long long fileSize; + if (!getFileSize(filePath, fileSize)) + return 0; + + PlatformFileHandle handle = openFile(filePath, OpenForRead); + int fileLength = static_cast<int>(fileSize); + Vector<char> buffer(fileLength); + readFromFile(handle, buffer.data(), fileLength); + closeFile(handle); + return SharedBuffer::adoptVector(buffer); +} + +TEST(WebImageTest, PNGImage) +{ + RefPtr<SharedBuffer> data = readFile("white-1x1.png"); + ASSERT_TRUE(data.get()); + + WebImage image = WebImage::fromData(WebData(data), WebSize()); + EXPECT_TRUE(image.size() == WebSize(1, 1)); + SkAutoLockPixels autoLock(image.getSkBitmap()); + EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), image.getSkBitmap().getColor(0, 0)); +} + +TEST(WebImageTest, ICOImage) +{ + RefPtr<SharedBuffer> data = readFile("black-and-white.ico"); + ASSERT_TRUE(data.get()); + + WebVector<WebImage> images = WebImage::framesFromData(WebData(data)); + ASSERT_EQ(2u, images.size()); + EXPECT_TRUE(images[0].size() == WebSize(2, 2)); + EXPECT_TRUE(images[1].size() == WebSize(1, 1)); + SkAutoLockPixels autoLock1(images[0].getSkBitmap()); + EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), images[0].getSkBitmap().getColor(0, 0)); + SkAutoLockPixels autoLock2(images[1].getSkBitmap()); + EXPECT_EQ(SkColorSetARGB(255, 0, 0, 0), images[1].getSkBitmap().getColor(0, 0)); +} + +TEST(WebImageTest, BadImage) +{ + const char badImage[] = "hello world"; + WebVector<WebImage> images = WebImage::framesFromData(WebData(badImage)); + ASSERT_EQ(0u, images.size()); + + WebImage image = WebImage::fromData(WebData(badImage), WebSize()); + EXPECT_TRUE(image.getSkBitmap().empty()); + EXPECT_TRUE(image.getSkBitmap().isNull()); +} + +} // namespace diff --git a/Source/WebKit/chromium/tests/WebViewTest.cpp b/Source/WebKit/chromium/tests/WebViewTest.cpp index b7ab658de..d478aad92 100644 --- a/Source/WebKit/chromium/tests/WebViewTest.cpp +++ b/Source/WebKit/chromium/tests/WebViewTest.cpp @@ -120,6 +120,40 @@ private: bool m_focused; }; +class TapHandlingWebViewClient : public WebViewClient { +public: + // WebViewClient methods + virtual void didHandleGestureEvent(const WebGestureEvent& event, bool handled) + { + if (event.type == WebInputEvent::GestureTap) { + m_tapX = event.x; + m_tapY = event.y; + } else if (event.type == WebInputEvent::GestureLongPress) { + m_longpressX = event.x; + m_longpressY = event.y; + } + } + + // Local methods + void reset() + { + m_tapX = -1; + m_tapY = -1; + m_longpressX = -1; + m_longpressY = -1; + } + int tapX() { return m_tapX; } + int tapY() { return m_tapY; } + int longpressX() { return m_longpressX; } + int longpressY() { return m_longpressY; } + +private: + int m_tapX; + int m_tapY; + int m_longpressX; + int m_longpressY; +}; + class WebViewTest : public testing::Test { public: WebViewTest() @@ -589,4 +623,28 @@ TEST_F(WebViewTest, DetectContentAroundPosition) webView->close(); } +TEST_F(WebViewTest, ClientTapHandling) +{ + TapHandlingWebViewClient client; + client.reset(); + WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true, 0, &client); + WebGestureEvent event; + event.type = WebInputEvent::GestureTap; + event.x = 3; + event.y = 8; + webView->handleInputEvent(event); + webkit_support::RunAllPendingMessages(); + EXPECT_EQ(3, client.tapX()); + EXPECT_EQ(8, client.tapY()); + client.reset(); + event.type = WebInputEvent::GestureLongPress; + event.x = 25; + event.y = 7; + webView->handleInputEvent(event); + webkit_support::RunAllPendingMessages(); + EXPECT_EQ(25, client.longpressX()); + EXPECT_EQ(7, client.longpressY()); + webView->close(); +} + } diff --git a/Source/WebKit/chromium/tests/data/black-and-white.ico b/Source/WebKit/chromium/tests/data/black-and-white.ico Binary files differnew file mode 100644 index 000000000..6bdf9ca4f --- /dev/null +++ b/Source/WebKit/chromium/tests/data/black-and-white.ico diff --git a/Source/WebKit/chromium/tests/data/white-1x1.png b/Source/WebKit/chromium/tests/data/white-1x1.png Binary files differnew file mode 100644 index 000000000..ccf7a6ca0 --- /dev/null +++ b/Source/WebKit/chromium/tests/data/white-1x1.png |
