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

Side by Side Diff: third_party/WebKit/Source/web/WebPluginContainerImpl.cpp

Issue 1413523007: Simplify computation of the invalidation rect for a frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « third_party/WebKit/Source/web/WebPluginContainerImpl.h ('k') | no next file » | 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) 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/frame/EventHandlerRegistry.h" 48 #include "core/frame/EventHandlerRegistry.h"
49 #include "core/frame/FrameView.h" 49 #include "core/frame/FrameView.h"
50 #include "core/frame/LocalFrame.h" 50 #include "core/frame/LocalFrame.h"
51 #include "core/frame/csp/ContentSecurityPolicy.h" 51 #include "core/frame/csp/ContentSecurityPolicy.h"
52 #include "core/html/HTMLFormElement.h" 52 #include "core/html/HTMLFormElement.h"
53 #include "core/html/HTMLPlugInElement.h" 53 #include "core/html/HTMLPlugInElement.h"
54 #include "core/input/EventHandler.h" 54 #include "core/input/EventHandler.h"
55 #include "core/layout/HitTestResult.h" 55 #include "core/layout/HitTestResult.h"
56 #include "core/layout/LayoutBox.h" 56 #include "core/layout/LayoutBox.h"
57 #include "core/layout/LayoutPart.h" 57 #include "core/layout/LayoutPart.h"
58 #include "core/layout/LayoutView.h"
58 #include "core/loader/FrameLoadRequest.h" 59 #include "core/loader/FrameLoadRequest.h"
59 #include "core/page/FocusController.h" 60 #include "core/page/FocusController.h"
60 #include "core/page/Page.h" 61 #include "core/page/Page.h"
61 #include "core/page/scrolling/ScrollingCoordinator.h" 62 #include "core/page/scrolling/ScrollingCoordinator.h"
62 #include "core/paint/LayoutObjectDrawingRecorder.h" 63 #include "core/paint/LayoutObjectDrawingRecorder.h"
63 #include "core/paint/PaintLayer.h" 64 #include "core/paint/PaintLayer.h"
64 #include "modules/plugins/PluginOcclusionSupport.h" 65 #include "modules/plugins/PluginOcclusionSupport.h"
65 #include "platform/HostWindow.h" 66 #include "platform/HostWindow.h"
66 #include "platform/KeyboardCodes.h" 67 #include "platform/KeyboardCodes.h"
67 #include "platform/PlatformGestureEvent.h" 68 #include "platform/PlatformGestureEvent.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 414
414 void WebPluginContainerImpl::reportGeometry() 415 void WebPluginContainerImpl::reportGeometry()
415 { 416 {
416 // We cannot compute geometry without a parent or layoutObject. 417 // We cannot compute geometry without a parent or layoutObject.
417 if (!parent() || !m_element || !m_element->layoutObject()) 418 if (!parent() || !m_element || !m_element->layoutObject())
418 return; 419 return;
419 420
420 IntRect windowRect, clipRect, unobscuredRect; 421 IntRect windowRect, clipRect, unobscuredRect;
421 Vector<IntRect> cutOutRects; 422 Vector<IntRect> cutOutRects;
422 calculateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects); 423 calculateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects);
423
424 m_webPlugin->updateGeometry(windowRect, clipRect, unobscuredRect, cutOutRect s, isVisible()); 424 m_webPlugin->updateGeometry(windowRect, clipRect, unobscuredRect, cutOutRect s, isVisible());
425 } 425 }
426 426
427 void WebPluginContainerImpl::allowScriptObjects() 427 void WebPluginContainerImpl::allowScriptObjects()
428 { 428 {
429 } 429 }
430 430
431 void WebPluginContainerImpl::clearScriptObjects() 431 void WebPluginContainerImpl::clearScriptObjects()
432 { 432 {
433 if (!frame()) 433 if (!frame())
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 return; 937 return;
938 938
939 LayoutBox* layoutObject = toLayoutBox(m_element->layoutObject()); 939 LayoutBox* layoutObject = toLayoutBox(m_element->layoutObject());
940 if (!layoutObject) 940 if (!layoutObject)
941 return; 941 return;
942 942
943 layoutObject->invalidatePaintRectangle(LayoutRect(m_pendingInvalidationRect) ); 943 layoutObject->invalidatePaintRectangle(LayoutRect(m_pendingInvalidationRect) );
944 m_pendingInvalidationRect = IntRect(); 944 m_pendingInvalidationRect = IntRect();
945 } 945 }
946 946
947 void WebPluginContainerImpl::computeClipRectsForPlugin(
948 const HTMLFrameOwnerElement* ownerElement, IntRect& windowRect, IntRect& cli ppedLocalRect, IntRect& unclippedIntLocalRect) const
949 {
950 ASSERT(ownerElement);
951
952 if (!ownerElement->layoutObject()) {
953 clippedLocalRect = IntRect();
954 unclippedIntLocalRect = IntRect();
955 return;
956 }
957
958 LayoutView* rootView = m_element->document().view()->layoutView();
959 while (rootView->frame()->ownerLayoutObject())
960 rootView = rootView->frame()->ownerLayoutObject()->view();
961
962 LayoutBox* box = toLayoutBox(ownerElement->layoutObject());
963
964 // Plugin frameRects are in absolute screen space.
965 IntRect frameRectInOwnerElementSpace = box->absoluteToLocalQuad(FloatRect(fr ameRect()), UseTransforms).enclosingBoundingBox();
966
967 LayoutRect unclippedAbsoluteRect(frameRectInOwnerElementSpace);
968 box->mapRectToPaintInvalidationBacking(rootView, unclippedAbsoluteRect, null ptr);
969
970 // The frameRect is already in absolute space.
971 windowRect = frameRect();
972
973 clippedLocalRect = enclosingIntRect(unclippedAbsoluteRect);
974 unclippedIntLocalRect = clippedLocalRect;
975 clippedLocalRect.intersect(rootView->frameView()->visibleContentRect());
976
977 // TODO(chrishtr): intentionally ignore transform, because the positioning o f frameRect() does also. This is probably wrong.
978 unclippedIntLocalRect = box->absoluteToLocalQuad(FloatRect(unclippedIntLocal Rect)).enclosingBoundingBox();
979 clippedLocalRect = box->absoluteToLocalQuad(FloatRect(clippedLocalRect)).enc losingBoundingBox();
980 }
981
947 void WebPluginContainerImpl::calculateGeometry(IntRect& windowRect, IntRect& cli pRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects) 982 void WebPluginContainerImpl::calculateGeometry(IntRect& windowRect, IntRect& cli pRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects)
948 { 983 {
949 windowRect = toFrameView(parent())->contentsToRootFrame(frameRect());
950
951 // Calculate a clip-rect so that we don't overlap the scrollbars, etc.
952 clipRect = convertToContainingWindow(IntRect(0, 0, width(), height()));
953 unobscuredRect = clipRect;
954
955 // document().layoutView() can be 0 when we receive messages from the 984 // document().layoutView() can be 0 when we receive messages from the
956 // plugins while we are destroying a frame. 985 // plugins while we are destroying a frame.
957 // FIXME: Can we just check m_element->document().isActive() ? 986 // FIXME: Can we just check m_element->document().isActive() ?
958 if (m_element->layoutObject()->document().layoutView()) { 987 if (m_element->layoutObject()->document().layoutView()) {
959 // Take our element and get the clip rect from the enclosing layer and 988 // Take our element and get the clip rect from the enclosing layer and
960 // frame view. 989 // frame view.
961 IntRect elementUnobscuredRect; 990 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t);
962 IntRect elementWindowClipRect = m_element->document().view()->clipRectsF orFrameOwner(m_element, &elementUnobscuredRect);
963 clipRect.intersect(elementWindowClipRect);
964 unobscuredRect.intersect(elementUnobscuredRect);
965 } 991 }
966
967 clipRect.move(-windowRect.x(), -windowRect.y());
968 unobscuredRect.move(-windowRect.x(), -windowRect.y());
969
970 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); 992 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
971 // Convert to the plugin position. 993 // Convert to the plugin position.
972 for (size_t i = 0; i < cutOutRects.size(); i++) 994 for (size_t i = 0; i < cutOutRects.size(); i++)
973 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 995 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
974 } 996 }
975 997
976 } // namespace blink 998 } // namespace blinkf
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPluginContainerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698