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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp

Issue 2127213002: Avoid lossy effects of rounding by using contentBoxRect directly for plugin bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 DCHECK(webView); 498 DCHECK(webView);
499 webView->settings()->setPluginsEnabled(true); 499 webView->settings()->setPluginsEnabled(true);
500 webView->resize(WebSize(300, 300)); 500 webView->resize(WebSize(300, 300));
501 webView->updateAllLifecyclePhases(); 501 webView->updateAllLifecyclePhases();
502 runPendingTasks(); 502 runPendingTasks();
503 503
504 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge tElementById("translated-plugin"); 504 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge tElementById("translated-plugin");
505 WebPluginContainerImpl* pluginContainerImpl = toWebPluginContainerImpl(plugi nElement.pluginContainer()); 505 WebPluginContainerImpl* pluginContainerImpl = toWebPluginContainerImpl(plugi nElement.pluginContainer());
506 506
507 DCHECK(pluginContainerImpl); 507 DCHECK(pluginContainerImpl);
508 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));
509 508
510 IntRect windowRect, clipRect, unobscuredRect; 509 IntRect windowRect, clipRect, unobscuredRect;
511 Vector<IntRect> cutOutRects; 510 Vector<IntRect> cutOutRects;
512 calculateGeometry(pluginContainerImpl, windowRect, clipRect, unobscuredRect, cutOutRects); 511 calculateGeometry(pluginContainerImpl, windowRect, clipRect, unobscuredRect, cutOutRects);
513 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); 512 EXPECT_RECT_EQ(IntRect(20, 220, 40, 40), windowRect);
514 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); 513 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), clipRect);
515 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); 514 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), unobscuredRect);
516 515
517 // Cause the plugin's frame to be detached. 516 // Cause the plugin's frame to be detached.
518 webViewHelper.reset(); 517 webViewHelper.reset();
519 } 518 }
520 519
521 TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) 520 TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin)
522 { 521 {
523 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("plugin_container.html")); 522 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("plugin_container.html"));
524 523
525 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper . 524 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper .
526 FrameTestHelpers::WebViewHelper webViewHelper; 525 FrameTestHelpers::WebViewHelper webViewHelper;
527 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient); 526 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient);
528 DCHECK(webView); 527 DCHECK(webView);
529 webView->settings()->setPluginsEnabled(true); 528 webView->settings()->setPluginsEnabled(true);
530 webView->resize(WebSize(300, 300)); 529 webView->resize(WebSize(300, 300));
531 webView->updateAllLifecyclePhases(); 530 webView->updateAllLifecyclePhases();
532 runPendingTasks(); 531 runPendingTasks();
533 532
534 WebElement pluginElement = webView->mainFrame()->document().getElementById(" subpixel-positioned-plugin"); 533 WebElement pluginElement = webView->mainFrame()->document().getElementById(" subpixel-positioned-plugin");
535 WebPluginContainerImpl* pluginContainerImpl = toWebPluginContainerImpl(plugi nElement.pluginContainer()); 534 WebPluginContainerImpl* pluginContainerImpl = toWebPluginContainerImpl(plugi nElement.pluginContainer());
536 535
537 DCHECK(pluginContainerImpl); 536 DCHECK(pluginContainerImpl);
538 537
539 IntRect windowRect, clipRect, unobscuredRect; 538 IntRect windowRect, clipRect, unobscuredRect;
540 Vector<IntRect> cutOutRects; 539 Vector<IntRect> cutOutRects;
541 540
542 calculateGeometry(pluginContainerImpl, windowRect, clipRect, unobscuredRect, cutOutRects); 541 calculateGeometry(pluginContainerImpl, windowRect, clipRect, unobscuredRect, cutOutRects);
543 // TODO(chrishtr): these values should not be -1, they should be 0. They are -1 because WebPluginContainerImpl currently uses an IntRect for
544 // frameRect() to determine the position of the plugin, which results in a l oss of precision if it is actually subpixel positioned.
545 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), windowRect); 542 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), windowRect);
546 EXPECT_RECT_EQ(IntRect(-1, -1, 41, 41), clipRect); 543 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), clipRect);
547 EXPECT_RECT_EQ(IntRect(-1, -1, 41, 41), unobscuredRect); 544 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), unobscuredRect);
548 545
549 // Cause the plugin's frame to be detached. 546 // Cause the plugin's frame to be detached.
550 webViewHelper.reset(); 547 webViewHelper.reset();
551 } 548 }
552 549
553 TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) 550 TEST_F(WebPluginContainerTest, TopmostAfterDetachTest)
554 { 551 {
555 static WebRect topmostRect(10, 10, 40, 40); 552 static WebRect topmostRect(10, 10, 40, 40);
556 553
557 // Plugin that checks isRectTopmost in destroy(). 554 // Plugin that checks isRectTopmost in destroy().
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 runPendingTasks(); 683 runPendingTasks();
687 684
688 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin")); 685 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin"));
689 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); 686 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true);
690 687
691 runPendingTasks(); 688 runPendingTasks();
692 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand lers(EventHandlerRegistry::WheelEventBlocking)); 689 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand lers(EventHandlerRegistry::WheelEventBlocking));
693 } 690 }
694 691
695 } // namespace blink 692 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698