Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 286903011: Show DragImage when the dragged element or its parent has transform (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderObject.cpp ('k') | Source/web/tests/data/nodeimage.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/frame/FrameView.h" 50 #include "core/frame/FrameView.h"
51 #include "core/frame/LocalFrame.h" 51 #include "core/frame/LocalFrame.h"
52 #include "core/frame/Settings.h" 52 #include "core/frame/Settings.h"
53 #include "core/html/HTMLFormElement.h" 53 #include "core/html/HTMLFormElement.h"
54 #include "core/loader/FrameLoadRequest.h" 54 #include "core/loader/FrameLoadRequest.h"
55 #include "core/page/EventHandler.h" 55 #include "core/page/EventHandler.h"
56 #include "core/rendering/HitTestResult.h" 56 #include "core/rendering/HitTestResult.h"
57 #include "core/rendering/RenderView.h" 57 #include "core/rendering/RenderView.h"
58 #include "core/rendering/TextAutosizer.h" 58 #include "core/rendering/TextAutosizer.h"
59 #include "core/rendering/compositing/RenderLayerCompositor.h" 59 #include "core/rendering/compositing/RenderLayerCompositor.h"
60 #include "platform/DragImage.h"
60 #include "platform/UserGestureIndicator.h" 61 #include "platform/UserGestureIndicator.h"
61 #include "platform/geometry/FloatRect.h" 62 #include "platform/geometry/FloatRect.h"
62 #include "platform/network/ResourceError.h" 63 #include "platform/network/ResourceError.h"
63 #include "platform/scroll/ScrollbarTheme.h" 64 #include "platform/scroll/ScrollbarTheme.h"
64 #include "public/platform/Platform.h" 65 #include "public/platform/Platform.h"
65 #include "public/platform/WebFloatRect.h" 66 #include "public/platform/WebFloatRect.h"
66 #include "public/platform/WebThread.h" 67 #include "public/platform/WebThread.h"
67 #include "public/platform/WebURL.h" 68 #include "public/platform/WebURL.h"
68 #include "public/platform/WebURLResponse.h" 69 #include "public/platform/WebURLResponse.h"
69 #include "public/platform/WebUnitTestSupport.h" 70 #include "public/platform/WebUnitTestSupport.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 settings->setCompositedScrollingForFramesEnabled(true); 163 settings->setCompositedScrollingForFramesEnabled(true);
163 } 164 }
164 165
165 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers ::WebViewHelper* webViewHelper) 166 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers ::WebViewHelper* webViewHelper)
166 { 167 {
167 webViewHelper->initializeAndLoad(url, true); 168 webViewHelper->initializeAndLoad(url, true);
168 webViewHelper->webView()->settings()->setDefaultFontSize(12); 169 webViewHelper->webView()->settings()->setDefaultFontSize(12);
169 webViewHelper->webView()->resize(WebSize(640, 480)); 170 webViewHelper->webView()->resize(WebSize(640, 480));
170 } 171 }
171 172
173 PassOwnPtr<WebCore::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewH elper* webViewHelper, const std::string& testcase)
174 {
175 registerMockedHttpURLLoad("nodeimage.html");
176 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html");
177 webViewHelper->webView()->resize(WebSize(640, 480));
178 webViewHelper->webView()->layout();
179 RefPtr<WebCore::LocalFrame> frame = webViewHelper->webViewImpl()->page() ->mainFrame();
180 WebCore::Element* element = frame->document()->getElementById(testcase.c _str());
181 return frame->nodeImage(*element);
182 }
183
172 std::string m_baseURL; 184 std::string m_baseURL;
173 std::string m_chromeURL; 185 std::string m_chromeURL;
174 }; 186 };
175 187
176 class UseMockScrollbarSettings { 188 class UseMockScrollbarSettings {
177 public: 189 public:
178 UseMockScrollbarSettings() 190 UseMockScrollbarSettings()
179 { 191 {
180 WebCore::Settings::setMockScrollbarsEnabled(true); 192 WebCore::Settings::setMockScrollbarsEnabled(true);
181 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); 193 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
(...skipping 5303 matching lines...) Expand 10 before | Expand all | Expand 10 after
5485 // Check that a reload ignoring cache on a frame will result in the cache 5497 // Check that a reload ignoring cache on a frame will result in the cache
5486 // policy of the request being set to ReloadBypassingCache. 5498 // policy of the request being set to ReloadBypassingCache.
5487 registerMockedHttpURLLoad("foo.html"); 5499 registerMockedHttpURLLoad("foo.html");
5488 FrameTestHelpers::WebViewHelper webViewHelper; 5500 FrameTestHelpers::WebViewHelper webViewHelper;
5489 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); 5501 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true);
5490 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5502 WebFrame* frame = webViewHelper.webView()->mainFrame();
5491 FrameTestHelpers::reloadFrameIgnoringCache(frame); 5503 FrameTestHelpers::reloadFrameIgnoringCache(frame);
5492 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request( ).cachePolicy()); 5504 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request( ).cachePolicy());
5493 } 5505 }
5494 5506
5507 TEST_F(WebFrameTest, NodeImageTestCSSTransform)
5508 {
5509 FrameTestHelpers::WebViewHelper webViewHelper;
5510 OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-transform"));
5511 EXPECT_TRUE(dragImage);
5512
5513 SkBitmap bitmap;
5514 ASSERT_TRUE(bitmap.allocN32Pixels(40, 40));
5515 SkCanvas canvas(bitmap);
5516 canvas.drawColor(SK_ColorGREEN);
5517
5518 EXPECT_EQ(40, dragImage->size().width());
5519 EXPECT_EQ(40, dragImage->size().height());
5520 const SkBitmap& dragBitmap = dragImage->bitmap();
5521 SkAutoLockPixels lockPixel(dragBitmap);
5522 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze()));
5523 }
5524
5525 TEST_F(WebFrameTest, NodeImageTestCSS3DTransform)
5526 {
5527 FrameTestHelpers::WebViewHelper webViewHelper;
5528 OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-3dtransform"));
5529 EXPECT_TRUE(dragImage);
5530
5531 SkBitmap bitmap;
5532 ASSERT_TRUE(bitmap.allocN32Pixels(20, 40));
5533 SkCanvas canvas(bitmap);
5534 canvas.drawColor(SK_ColorGREEN);
5535
5536 EXPECT_EQ(20, dragImage->size().width());
5537 EXPECT_EQ(40, dragImage->size().height());
5538 const SkBitmap& dragBitmap = dragImage->bitmap();
5539 SkAutoLockPixels lockPixel(dragBitmap);
5540 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze()));
5541 }
5542
5495 } // namespace 5543 } // namespace
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.cpp ('k') | Source/web/tests/data/nodeimage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698