Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // TODO(chrishtr): intentionally ignore transform, because the positioning o f frameRect() does also. This is probably wrong. |
|
Xianzhu
2016/07/07 18:49:57
Nit: Remove the TODO.
chrishtr
2016/07/07 20:02:14
Done.
| |
| 926 unclippedIntLocalRect = box->absoluteToLocalQuad(FloatRect(unclippedLayoutLo calRect), TraverseDocumentBoundaries).enclosingBoundingBox(); | 925 unclippedIntLocalRect = box->absoluteToLocalQuad(FloatRect(unclippedLayoutLo calRect), TraverseDocumentBoundaries | UseTransforms).enclosingBoundingBox(); |
| 927 // As a performance optimization, map the clipped rect separately if is diff erent than the unclipped rect. | 926 // As a performance optimization, map the clipped rect separately if is diff erent than the unclipped rect. |
| 928 if (layoutClippedLocalRect != unclippedLayoutLocalRect) | 927 if (layoutClippedLocalRect != unclippedLayoutLocalRect) |
| 929 clippedLocalRect = box->absoluteToLocalQuad(FloatRect(layoutClippedLocal Rect), TraverseDocumentBoundaries).enclosingBoundingBox(); | 928 clippedLocalRect = box->absoluteToLocalQuad(FloatRect(layoutClippedLocal Rect), TraverseDocumentBoundaries | UseTransforms).enclosingBoundingBox(); |
| 930 else | 929 else |
| 931 clippedLocalRect = unclippedIntLocalRect; | 930 clippedLocalRect = unclippedIntLocalRect; |
| 932 } | 931 } |
| 933 | 932 |
| 934 void WebPluginContainerImpl::calculateGeometry(IntRect& windowRect, IntRect& cli pRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects) | 933 void WebPluginContainerImpl::calculateGeometry(IntRect& windowRect, IntRect& cli pRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects) |
| 935 { | 934 { |
| 936 // document().layoutView() can be null when we receive messages from the | 935 // document().layoutView() can be null when we receive messages from the |
| 937 // plugins while we are destroying a frame. | 936 // plugins while we are destroying a frame. |
| 938 // FIXME: Can we just check m_element->document().isActive() ? | 937 // FIXME: Can we just check m_element->document().isActive() ? |
| 939 if (m_element->layoutObject()->document().layoutView()) { | 938 if (m_element->layoutObject()->document().layoutView()) { |
| 940 // Take our element and get the clip rect from the enclosing layer and | 939 // Take our element and get the clip rect from the enclosing layer and |
| 941 // frame view. | 940 // frame view. |
| 942 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t); | 941 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t); |
| 943 } | 942 } |
| 944 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); | 943 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); |
| 945 // Convert to the plugin position. | 944 // Convert to the plugin position. |
| 946 for (size_t i = 0; i < cutOutRects.size(); i++) | 945 for (size_t i = 0; i < cutOutRects.size(); i++) |
| 947 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); | 946 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); |
| 948 } | 947 } |
| 949 | 948 |
| 950 } // namespace blink | 949 } // namespace blink |
| OLD | NEW |