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

Side by Side Diff: third_party/WebKit/Source/web/WebPluginContainerImpl.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: none 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 unclippedIntLocalRect = IntRect(); 896 unclippedIntLocalRect = IntRect();
897 return; 897 return;
898 } 898 }
899 899
900 LayoutView* rootView = m_element->document().view()->layoutView(); 900 LayoutView* rootView = m_element->document().view()->layoutView();
901 while (rootView->frame()->ownerLayoutObject()) 901 while (rootView->frame()->ownerLayoutObject())
902 rootView = rootView->frame()->ownerLayoutObject()->view(); 902 rootView = rootView->frame()->ownerLayoutObject()->view();
903 903
904 LayoutBox* box = toLayoutBox(ownerElement->layoutObject()); 904 LayoutBox* box = toLayoutBox(ownerElement->layoutObject());
905 905
906 // Plugin frameRects are in absolute space within their frame. 906 // Note: frameRect() for this plugin is equal to contentBoxRect, mapped to t he containing view space, and rounded off.
907 FloatRect frameRectInOwnerElementSpace = box->absoluteToLocalQuad(FloatRect( frameRect()), UseTransforms).boundingBox(); 907 // See LayoutPart.cpp::updateWidgetGeometryInternal. To remove the lossy eff ect of rounding off, use contentBoxRect directly.
908 908 LayoutRect unclippedAbsoluteRect(box->contentBoxRect());
909 LayoutRect unclippedAbsoluteRect(frameRectInOwnerElementSpace);
910 box->mapToVisualRectInAncestorSpace(rootView, unclippedAbsoluteRect); 909 box->mapToVisualRectInAncestorSpace(rootView, unclippedAbsoluteRect);
911 910
912 // The frameRect is already in absolute space of the local frame to the plug in. 911 // The frameRect is already in absolute space of the local frame to the plug in.
913 windowRect = frameRect(); 912 windowRect = frameRect();
914 // Map up to the root frame. 913 // Map up to the root frame.
915 LayoutRect layoutWindowRect = 914 LayoutRect layoutWindowRect =
916 LayoutRect(m_element->document().view()->layoutView()->localToAbsoluteQu ad(FloatQuad(FloatRect(frameRect())), TraverseDocumentBoundaries).boundingBox()) ; 915 LayoutRect(m_element->document().view()->layoutView()->localToAbsoluteQu ad(FloatQuad(FloatRect(frameRect())), TraverseDocumentBoundaries).boundingBox()) ;
917 // Finally, adjust for scrolling of the root frame, which the above does not take into account. 916 // Finally, adjust for scrolling of the root frame, which the above does not take into account.
918 layoutWindowRect.moveBy(-rootView->viewRect().location()); 917 layoutWindowRect.moveBy(-rootView->viewRect().location());
919 windowRect = pixelSnappedIntRect(layoutWindowRect); 918 windowRect = pixelSnappedIntRect(layoutWindowRect);
920 919
921 LayoutRect layoutClippedLocalRect = unclippedAbsoluteRect; 920 LayoutRect layoutClippedLocalRect = unclippedAbsoluteRect;
922 LayoutRect unclippedLayoutLocalRect = layoutClippedLocalRect; 921 LayoutRect unclippedLayoutLocalRect = layoutClippedLocalRect;
923 layoutClippedLocalRect.intersect(LayoutRect(rootView->frameView()->visibleCo ntentRect())); 922 layoutClippedLocalRect.intersect(LayoutRect(rootView->frameView()->visibleCo ntentRect()));
924 923
925 // TODO(chrishtr): intentionally ignore transform, because the positioning o f frameRect() does also. This is probably wrong. 924 unclippedIntLocalRect = box->absoluteToLocalQuad(FloatRect(unclippedLayoutLo calRect), TraverseDocumentBoundaries | UseTransforms).enclosingBoundingBox();
926 unclippedIntLocalRect = box->absoluteToLocalQuad(FloatRect(unclippedLayoutLo calRect), TraverseDocumentBoundaries).enclosingBoundingBox();
927 // As a performance optimization, map the clipped rect separately if is diff erent than the unclipped rect. 925 // As a performance optimization, map the clipped rect separately if is diff erent than the unclipped rect.
928 if (layoutClippedLocalRect != unclippedLayoutLocalRect) 926 if (layoutClippedLocalRect != unclippedLayoutLocalRect)
929 clippedLocalRect = box->absoluteToLocalQuad(FloatRect(layoutClippedLocal Rect), TraverseDocumentBoundaries).enclosingBoundingBox(); 927 clippedLocalRect = box->absoluteToLocalQuad(FloatRect(layoutClippedLocal Rect), TraverseDocumentBoundaries | UseTransforms).enclosingBoundingBox();
930 else 928 else
931 clippedLocalRect = unclippedIntLocalRect; 929 clippedLocalRect = unclippedIntLocalRect;
932 } 930 }
933 931
934 void WebPluginContainerImpl::calculateGeometry(IntRect& windowRect, IntRect& cli pRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects) 932 void WebPluginContainerImpl::calculateGeometry(IntRect& windowRect, IntRect& cli pRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects)
935 { 933 {
936 // document().layoutView() can be null when we receive messages from the 934 // document().layoutView() can be null when we receive messages from the
937 // plugins while we are destroying a frame. 935 // plugins while we are destroying a frame.
938 // FIXME: Can we just check m_element->document().isActive() ? 936 // FIXME: Can we just check m_element->document().isActive() ?
939 if (m_element->layoutObject()->document().layoutView()) { 937 if (m_element->layoutObject()->document().layoutView()) {
940 // Take our element and get the clip rect from the enclosing layer and 938 // Take our element and get the clip rect from the enclosing layer and
941 // frame view. 939 // frame view.
942 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t); 940 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t);
943 } 941 }
944 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); 942 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
945 // Convert to the plugin position. 943 // Convert to the plugin position.
946 for (size_t i = 0; i < cutOutRects.size(); i++) 944 for (size_t i = 0; i < cutOutRects.size(); i++)
947 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 945 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
948 } 946 }
949 947
950 } // namespace blink 948 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698