mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
795ba7b999
- Bug 1222092. Don't let sFocusedIMEWidget keep an nsIWidget alive during shutdown. r=masayuki (f604e32bda) - Bug 1186795 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in widget/ with iterators. r=roc. (65077bd952) - Bug 1186795 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in widget/ with iterators. r=roc. (b468993d9a) - Bug 1186795 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in widget/ with iterators. r=roc. (29946ed0ce) - Bug 1217251 - Add APZThreadUtils::RunDelayedTaskOnCurrentThread(). r=kats (0a89e92202) - Bug 1223946 - Part 1: Clean up and support needed for converting WidgetWheelEvent to ScrollWheelInput. r=kats (faf54e7920) - Bug 1223946 - Part 2: Ensure wheel event from nsDOMWindowUtil is dispatched on correct thread. r=kats (571d591345) - Bug 1210912 - fix widget leak in LookupRegisteredPluginWindow; r=roc (f224933634) - Bug 1188225 - Implement ChromeProcessController::HandleDoubleTap. r=botond (ffc65ffec1) - Bug 1221371 - Remove unnecessary explicit copies of nsTArray. r=billm (3178318eb5) - Bug 1218991 - Save initial zoom constraints to be used once compositor is created r=kats (4017bdc17d) - Bug 1217818 - Add some more logging to more easily diagnose issues. r=botond (2a1480e209) - Bug 1219898 - Remove use of gPreventMouseEvents in APZ event state-tracking code. r=botond (d6877aaedf) - Bug 1211612 - Add DragInputBlock for async scrollbars. r=kats (6bfbcccead) - Bug 1225007 (part 1, attempt 3) - Use LayoutDevicePixel more in Cocoa widget code. r=kats. (e4078ce0ad) - Bug 1225007 (part 2, attempt 3) - Use LayoutDevicePixel more in Cocoa widget code. r=kats. (0db998bf01) - Bug 1214662 - Fix compile error for enabling APZES_LOG. r=botond (c316ba99cd) - Bug 1223296 - Clear element activation if a contextmenu is displayed. r=botond (e362ffcf8d) - Bug 1217818 - Minor refactoring to reuse a function. r=botond (c0c29e2b90) - Bug 1217818 - Ignore injected touchstart events for the purposes of prevent-default notifications back to APZ. r=botond (b740525b61) - Bug 1223296 - Turn HandlePanStart into a more generic function that can be called from other places. r=botond (d10991094a) - Bug 1223296 - Fire the MozMouseHittest event even if the C++ APZ is enabled. r=rbarker,botond (cdd7523a3b) - Bug 1184890 part.1 SelectionChangeDataBase and TextChangeDataBase should have a flag which indicates whether the change occurred during composition or not r=smaug (e10f782acb) - Bug 1184890 part.2 IMContextWrapper shouldn't commit composition when a selection change notification occurred before starting current composition r=m_kato (8f377bfc36) - Bug 1184890 part.3 TSFTextStore shouldn't commit composition when a selection change notification occurred before starting current composition r=m_kato (b55102256e) - Bug 1216177 - Remove the remaining nsRefPtr forward declarations; r=froydnj (a3674552c3) - Bug 1225571 - Move the code to update the SPCSPS from repaint request handling to when the resolution is updated in the presShell. r=botond (a7d1909ed5) - bug 1181823 - convert test_ev_certs.js, test_keysize_ev.js, and test_validity.js to generate certificates at build time r=Cykesiopka r=mgoodwin (19a2678625) - Bug 1189166 - Cleanup some PSM test generation files post Bug 1181823. r=dkeeler (fad638b365) - Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor (0c8e0229e7) - Bug 1208814 - Part 1: Add an analysis to prevent default copy constructors from being called on refcounted objects, r=ehsan (6a8605808e) - Bug 1208814 - Part 2: Don't use the default copy constructor in nsNavHistoryQuery::Clone(), r=ehsan (6de5b8a04c) - Bug 1201314 - Make most of std:: non-memmovable for static analysis purposes. r=mystor r=ehsan (3a50302fb6) - fix refptr (70035b7976) - Bug 1223966: Don't claim we support NSTextInput interface. r=masayuki (ab702c6718) - Bug 431620 - Remove unused function GetToggledKeyState [r=roc] (0c7140855c) - bug 1203312 - convert tlsserver to generate certificates at build time r=Cykesiopka,mgoodwin (ada3c01c00) - Bug 1194419 - Remove signature algorithm duplicate use in serial number determination in pycert. r=keeler (37c2fbe839) - Bug 1210180 - Force the view to update when we recycle a Vibrancy view. r=mstange (33490daf1f) - Bug 1142393 - Make menus look correct when 'Reduce transparency' is set. r=smichaud (0d8a1b9b7f) - Bug 1119106 - Add an explanatory comment. r=smichaud (1e44196dad) - Bug 1119106 - Increase the maximum focus ring width on 10.10 to 7 pixels. r=smichaud (1af85f99e8) - Bug 1119106 - Give these enums better names. r=smichaud (65886bdab6) - Bug 1153579 - Fix -Wsign-compare warnings in nsNativeThemeCocoa.mm about int and size_t. r=mstange (d682b281df) - some crash reporter stuff (3157fa0f2d) - bug 726483 remove unnecessary DispatchResized() parameters r=roc (02051fd152) - Bug 1208829 - Make FromUnknownRegion() actually work, and add ToUnknownRegion(). r=mstange (5a087ad3aa) - Bug 1180564: Don't implement NSTextInput any more, just NSTextInputClient. r=masayuki (7611a0d77c) - Bug 1180564: insertNewline should use TextInputHandler::InsertText() instead of using insertText of NSTextInput protocol r=masayuki (dc11c738b9) - Bug 1124408 - Report cocoa view focus correctly when sheets are exposed. r=masayuki,smichaud (34a6a32d8b) - Bug 1138678 - Ignore NOTIFY_IME_OF_BLUR when establishing secure input mode. r=masayuki (4d7b10e8a2) - Bug 1148196 - Crashes at -[ChildView keyDown:] related to secure input. r=masayuki (0cbd54b9cf) - Bug 1211352 part.1 IMEContentObserver should be created when a plugin has focus r=smaug (4500259e6f) - Bug 1211352 part.2 PuppetWidget shouldn't send notifications which are not wanted by the parent process r=m_kato (2557aa51b2) - Bug 1007063 - Show virtual (on-screen) keyboard in Windows 8 and higher when text fields are focused if physical keyboards are not present. r=jimm r=masayuki r=m_kato (9d2c1e62d0) - Bug 1211352 part.3 nsIWidget::GetIMEupdatePreference() for each platform should not request any notifications while a plugin has focus r=m_kato (1aa357bc9d) - Bug 1211352 part.4 PuppetWidget::GetIMEUpdatePreference() should request only position change notifications while a plugin has focus r=m_kato (470fb900d6) - Bug 1211352 part.5 PuppetWidget should cache only the focused editor rect information while a plugin has focus r=m_kato (73e7521d3c) - Bug 1223366 - Update event.buttons on GDK_BUTTON_RELEASE [r=karlt] (107c793c5a) - bug 726483 keep an extra reference to the window r=roc (4e6756939f) - Bug 1186745 part 1 - Add LeakRefPtr for pointer leaking by default. r=froydnj (b7260528df) - Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj (f408ef41da) - Bug 1186745 part 3 - Make nsThreadSyncDispatch leak the sync task by default when Run() is not called. r=froydnj (17092e33ab) - Bug 1186745 part 4 - Make TracedRunnable accept an already_AddRefed instead of a raw pointer. r=froydnj (8e59e1d0c9) - Bug 1186745 part 5 - Make nsThread::Dispatch() always leak the event if it fails. r=froydnj (220b91529a) - Bug 1186745 part 6 - Fix event leak when using NS_DispatchToCurrentThread. r=froydnj (55a4177f2e) - some crashreporter stuff (a5a59bd6ac) - bug 726483 avoid DispatchResized() during size-allocate r=roc (08ae527f93) - Bug 1212733, cache dnd window state instead of using gtk_window_get_type_hint, r=karlt (c9ee119926) - Bug 1131978 - Acknowledge GDK's scale factor in scale calculation. r=karlt (7280d547b8) - bug 1180008 provide gtk_window_get_window_type for old GTK versions r=glandium (3f7f17ac69) - Bug 1174374 - gdk_cursor_new() is deprecated in 3.16. Use gdk_cursor_new_for_display(). r=karlt (90e2e738f7)
676 lines
23 KiB
C++
676 lines
23 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: sw=2 ts=8 et :
|
|
*/
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "BasicLayers.h"
|
|
#include "gfxPrefs.h"
|
|
#ifdef MOZ_ENABLE_D3D9_LAYER
|
|
# include "LayerManagerD3D9.h"
|
|
#endif //MOZ_ENABLE_D3D9_LAYER
|
|
#include "mozilla/BrowserElementParent.h"
|
|
#include "mozilla/EventForwards.h" // for Modifiers
|
|
#include "mozilla/dom/ContentChild.h"
|
|
#include "mozilla/dom/TabParent.h"
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
|
#include "mozilla/layers/APZThreadUtils.h"
|
|
#include "mozilla/layers/CompositorParent.h"
|
|
#include "mozilla/layers/LayerTransactionParent.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsFocusManager.h"
|
|
#include "nsFrameLoader.h"
|
|
#include "nsIObserver.h"
|
|
#include "nsStyleStructInlines.h"
|
|
#include "nsSubDocumentFrame.h"
|
|
#include "nsView.h"
|
|
#include "nsViewportFrame.h"
|
|
#include "RenderFrameParent.h"
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
|
#include "mozilla/layers/CompositorChild.h"
|
|
#include "ClientLayerManager.h"
|
|
#include "FrameLayerBuilder.h"
|
|
|
|
#ifdef MOZ_ANDROID_APZ
|
|
#include "AndroidBridge.h"
|
|
#endif
|
|
|
|
using namespace mozilla::dom;
|
|
using namespace mozilla::gfx;
|
|
using namespace mozilla::layers;
|
|
|
|
namespace mozilla {
|
|
namespace layout {
|
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
|
|
|
/**
|
|
* Gets the layer-pixel offset of aContainerFrame's content rect top-left
|
|
* from the nearest display item reference frame (which we assume will be inducing
|
|
* a ContainerLayer).
|
|
*/
|
|
static nsIntPoint
|
|
GetContentRectLayerOffset(nsIFrame* aContainerFrame, nsDisplayListBuilder* aBuilder)
|
|
{
|
|
nscoord auPerDevPixel = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
// Offset to the content rect in case we have borders or padding
|
|
// Note that aContainerFrame could be a reference frame itself, so
|
|
// we need to be careful here to ensure that we call ToReferenceFrame
|
|
// on aContainerFrame and not its parent.
|
|
nsPoint frameOffset = aBuilder->ToReferenceFrame(aContainerFrame) +
|
|
aContainerFrame->GetContentRectRelativeToSelf().TopLeft();
|
|
|
|
return frameOffset.ToNearestPixels(auPerDevPixel);
|
|
}
|
|
|
|
// Return true iff |aManager| is a "temporary layer manager". They're
|
|
// used for small software rendering tasks, like drawWindow. That's
|
|
// currently implemented by a BasicLayerManager without a backing
|
|
// widget, and hence in non-retained mode.
|
|
inline static bool
|
|
IsTempLayerManager(LayerManager* aManager)
|
|
{
|
|
return (mozilla::layers::LayersBackend::LAYERS_BASIC == aManager->GetBackendType() &&
|
|
!static_cast<BasicLayerManager*>(aManager)->IsRetained());
|
|
}
|
|
|
|
already_AddRefed<LayerManager>
|
|
GetFrom(nsFrameLoader* aFrameLoader)
|
|
{
|
|
nsIDocument* doc = aFrameLoader->GetOwnerDoc();
|
|
if (!doc) {
|
|
return nullptr;
|
|
}
|
|
return nsContentUtils::LayerManagerForDocument(doc);
|
|
}
|
|
|
|
class RemoteContentController : public GeckoContentController {
|
|
public:
|
|
explicit RemoteContentController(RenderFrameParent* aRenderFrame)
|
|
: mUILoop(MessageLoop::current())
|
|
, mRenderFrame(aRenderFrame)
|
|
{ }
|
|
|
|
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) override
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->UpdateFrame(aFrameMetrics);
|
|
}
|
|
}
|
|
|
|
virtual void RequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
|
|
const mozilla::CSSPoint& aDestination) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::RequestFlingSnap,
|
|
aScrollId, aDestination));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->RequestFlingSnap(aScrollId, aDestination);
|
|
}
|
|
}
|
|
|
|
virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
|
|
const uint32_t& aScrollGeneration) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::AcknowledgeScrollUpdate,
|
|
aScrollId, aScrollGeneration));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
|
|
}
|
|
}
|
|
|
|
virtual void HandleDoubleTap(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap,
|
|
aPoint, aModifiers, aGuid));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleDoubleTap(aPoint, aModifiers, aGuid);
|
|
}
|
|
}
|
|
|
|
virtual void HandleSingleTap(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleSingleTap,
|
|
aPoint, aModifiers, aGuid));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
mRenderFrame->TakeFocusForClick();
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleSingleTap(aPoint, aModifiers, aGuid);
|
|
}
|
|
}
|
|
|
|
virtual void HandleLongTap(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid,
|
|
uint64_t aInputBlockId) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleLongTap,
|
|
aPoint, aModifiers, aGuid, aInputBlockId));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleLongTap(aPoint, aModifiers, aGuid, aInputBlockId);
|
|
}
|
|
}
|
|
|
|
void ClearRenderFrame() { mRenderFrame = nullptr; }
|
|
|
|
virtual void PostDelayedTask(Task* aTask, int aDelayMs) override
|
|
{
|
|
#ifdef MOZ_ANDROID_APZ
|
|
AndroidBridge::Bridge()->PostTaskToUiThread(aTask, aDelayMs);
|
|
#else
|
|
(MessageLoop::current() ? MessageLoop::current() : mUILoop)->
|
|
PostDelayedTask(FROM_HERE, aTask, aDelayMs);
|
|
#endif
|
|
}
|
|
|
|
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion) override
|
|
{
|
|
if (mTouchSensitiveRegion.IsEmpty())
|
|
return false;
|
|
|
|
*aOutRegion = CSSRect::FromAppUnits(mTouchSensitiveRegion.GetBounds());
|
|
return true;
|
|
}
|
|
|
|
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
|
|
APZStateChange aChange,
|
|
int aArg) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange,
|
|
aGuid, aChange, aArg));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->NotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
|
|
}
|
|
}
|
|
|
|
void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent) override {
|
|
if (MessageLoop::current() != mUILoop) {
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::NotifyMozMouseScrollEvent, aScrollId, aEvent));
|
|
return;
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->NotifyMouseScrollTestEvent(aScrollId, aEvent);
|
|
}
|
|
}
|
|
|
|
void NotifyFlushComplete() override {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->NotifyFlushComplete();
|
|
}
|
|
}
|
|
|
|
// Methods used by RenderFrameParent to set fields stored here.
|
|
|
|
void SetTouchSensitiveRegion(const nsRegion& aRegion)
|
|
{
|
|
mTouchSensitiveRegion = aRegion;
|
|
}
|
|
private:
|
|
MessageLoop* mUILoop;
|
|
RenderFrameParent* mRenderFrame;
|
|
|
|
nsRegion mTouchSensitiveRegion;
|
|
};
|
|
|
|
RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
|
uint64_t* aId,
|
|
bool* aSuccess)
|
|
: mLayersId(0)
|
|
, mFrameLoader(aFrameLoader)
|
|
, mFrameLoaderDestroyed(false)
|
|
, mAsyncPanZoomEnabled(false)
|
|
{
|
|
*aId = 0;
|
|
*aSuccess = false;
|
|
if (!mFrameLoader) {
|
|
return;
|
|
}
|
|
|
|
RefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
|
|
|
mAsyncPanZoomEnabled = lm && lm->AsyncPanZoomEnabled();
|
|
|
|
// Perhaps the document containing this frame currently has no presentation?
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
*aTextureFactoryIdentifier =
|
|
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
|
|
} else {
|
|
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
|
}
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
// Our remote frame will push layers updates to the compositor,
|
|
// and we'll keep an indirect reference to that tree.
|
|
*aId = mLayersId = CompositorParent::AllocateLayerTreeId();
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
ClientLayerManager *clientManager =
|
|
static_cast<ClientLayerManager*>(lm.get());
|
|
clientManager->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId);
|
|
}
|
|
if (mAsyncPanZoomEnabled) {
|
|
mContentController = new RemoteContentController(this);
|
|
CompositorParent::SetControllerForLayerTree(mLayersId, mContentController);
|
|
}
|
|
} else if (XRE_IsContentProcess()) {
|
|
ContentChild::GetSingleton()->SendAllocateLayerTreeId(aId);
|
|
mLayersId = *aId;
|
|
CompositorChild::Get()->SendNotifyChildCreated(mLayersId);
|
|
}
|
|
*aSuccess = true;
|
|
}
|
|
|
|
APZCTreeManager*
|
|
RenderFrameParent::GetApzcTreeManager()
|
|
{
|
|
// We can't get a ref to the APZCTreeManager until after the child is
|
|
// created and the static getter knows which CompositorParent is
|
|
// instantiated with this layers ID. That's why try to fetch it when
|
|
// we first need it and cache the result.
|
|
// Note: the IsParentProcess check is to deal with nested content process
|
|
// scenarios, since in those cases we can have RenderFrameParent instances
|
|
// in a child process, but the APZC machinery is not in that process. Bug
|
|
// 1020199 should fix this more comprehensively.
|
|
if (!mApzcTreeManager && mAsyncPanZoomEnabled && XRE_IsParentProcess()) {
|
|
mApzcTreeManager = CompositorParent::GetAPZCTreeManager(mLayersId);
|
|
}
|
|
return mApzcTreeManager.get();
|
|
}
|
|
|
|
RenderFrameParent::~RenderFrameParent()
|
|
{}
|
|
|
|
void
|
|
RenderFrameParent::Destroy()
|
|
{
|
|
mFrameLoaderDestroyed = true;
|
|
}
|
|
|
|
already_AddRefed<Layer>
|
|
RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame,
|
|
LayerManager* aManager,
|
|
const nsIntRect& aVisibleRect,
|
|
nsDisplayItem* aItem,
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
{
|
|
MOZ_ASSERT(aFrame,
|
|
"makes no sense to have a shadow tree without a frame");
|
|
MOZ_ASSERT(!mContainer ||
|
|
IsTempLayerManager(aManager) ||
|
|
mContainer->Manager() == aManager,
|
|
"retaining manager changed out from under us ... HELP!");
|
|
|
|
if (IsTempLayerManager(aManager) ||
|
|
(mContainer && mContainer->Manager() != aManager)) {
|
|
// This can happen if aManager is a "temporary" manager, or if the
|
|
// widget's layer manager changed out from under us. We need to
|
|
// FIXME handle the former case somehow, probably with an API to
|
|
// draw a manager's subtree. The latter is bad bad bad, but the the
|
|
// MOZ_ASSERT() above will flag it. Returning nullptr here will just
|
|
// cause the shadow subtree not to be rendered.
|
|
if (!aContainerParameters.mForEventsOnly) {
|
|
NS_WARNING("Remote iframe not rendered");
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
uint64_t id = GetLayerTreeId();
|
|
if (!id) {
|
|
return nullptr;
|
|
}
|
|
|
|
RefPtr<Layer> layer =
|
|
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
|
if (!layer) {
|
|
layer = aManager->CreateRefLayer();
|
|
}
|
|
if (!layer) {
|
|
// Probably a temporary layer manager that doesn't know how to
|
|
// use ref layers.
|
|
return nullptr;
|
|
}
|
|
static_cast<RefLayer*>(layer.get())->SetReferentId(id);
|
|
nsIntPoint offset = GetContentRectLayerOffset(aFrame, aBuilder);
|
|
// We can only have an offset if we're a child of an inactive
|
|
// container, but our display item is LAYER_ACTIVE_FORCE which
|
|
// forces all layers above to be active.
|
|
MOZ_ASSERT(aContainerParameters.mOffset == nsIntPoint());
|
|
gfx::Matrix4x4 m = gfx::Matrix4x4::Translation(offset.x, offset.y, 0.0);
|
|
// Remote content can't be repainted by us, so we multiply down
|
|
// the resolution that our container expects onto our container.
|
|
m.PreScale(aContainerParameters.mXScale, aContainerParameters.mYScale, 1.0);
|
|
layer->SetBaseTransform(m);
|
|
|
|
return layer.forget();
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
|
|
{
|
|
MOZ_ASSERT(!mFrameLoader || mFrameLoader->GetOwnerContent() == aContent,
|
|
"Don't build new map if owner is same!");
|
|
|
|
RefPtr<LayerManager> lm = mFrameLoader ? GetFrom(mFrameLoader) : nullptr;
|
|
// Perhaps the document containing this frame currently has no presentation?
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
ClientLayerManager *clientManager =
|
|
static_cast<ClientLayerManager*>(lm.get());
|
|
clientManager->GetRemoteRenderer()->SendAdoptChild(mLayersId);
|
|
}
|
|
// The APZCTreeManager associated with this RenderFrameParent may have changed
|
|
// so reset it and let GetApzcTreeManager() pick it up again.
|
|
mApzcTreeManager = nullptr;
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::ActorDestroy(ActorDestroyReason why)
|
|
{
|
|
if (mLayersId != 0) {
|
|
if (XRE_IsContentProcess()) {
|
|
ContentChild::GetSingleton()->SendDeallocateLayerTreeId(mLayersId);
|
|
} else {
|
|
CompositorParent::DeallocateLayerTreeId(mLayersId);
|
|
}
|
|
if (mContentController) {
|
|
// Stop our content controller from requesting repaints of our
|
|
// content.
|
|
mContentController->ClearRenderFrame();
|
|
// TODO: notify the compositor?
|
|
}
|
|
}
|
|
|
|
mFrameLoader = nullptr;
|
|
}
|
|
|
|
bool
|
|
RenderFrameParent::RecvNotifyCompositorTransaction()
|
|
{
|
|
TriggerRepaint();
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
RenderFrameParent::RecvUpdateHitRegion(const nsRegion& aRegion)
|
|
{
|
|
mTouchRegion = aRegion;
|
|
if (mContentController) {
|
|
// Tell the content controller about the touch-sensitive region, so
|
|
// that it can provide it to APZ. This is required for APZ to do
|
|
// correct hit testing for a remote 'mozpasspointerevents' iframe
|
|
// until bug 928833 is fixed.
|
|
mContentController->SetTouchSensitiveRegion(aRegion);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::TriggerRepaint()
|
|
{
|
|
nsIFrame* docFrame = mFrameLoader->GetPrimaryFrameOfOwningContent();
|
|
if (!docFrame) {
|
|
// Bad, but nothing we can do about it (XXX/cjones: or is there?
|
|
// maybe bug 589337?). When the new frame is created, we'll
|
|
// probably still be the current render frame and will get to draw
|
|
// our content then. Or, we're shutting down and this update goes
|
|
// to /dev/null.
|
|
return;
|
|
}
|
|
|
|
docFrame->InvalidateLayer(nsDisplayItem::TYPE_REMOTE);
|
|
}
|
|
|
|
uint64_t
|
|
RenderFrameParent::GetLayerTreeId() const
|
|
{
|
|
return mLayersId;
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
nsSubDocumentFrame* aFrame,
|
|
const nsRect& aDirtyRect,
|
|
const nsDisplayListSet& aLists)
|
|
{
|
|
// We're the subdoc for <browser remote="true"> and it has
|
|
// painted content. Display its shadow layer tree.
|
|
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
|
|
|
nsPoint offset = aBuilder->ToReferenceFrame(aFrame);
|
|
nsRect bounds = aFrame->EnsureInnerView()->GetBounds() + offset;
|
|
clipState.ClipContentDescendants(bounds);
|
|
|
|
aLists.Content()->AppendToTop(
|
|
new (aBuilder) nsDisplayRemote(aBuilder, aFrame, this));
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::ZoomToRect(uint32_t aPresShellId, ViewID aViewId,
|
|
const CSSRect& aRect)
|
|
{
|
|
if (GetApzcTreeManager()) {
|
|
GetApzcTreeManager()->ZoomToRect(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
|
|
aRect);
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid,
|
|
uint64_t aInputBlockId,
|
|
bool aPreventDefault)
|
|
{
|
|
if (aGuid.mLayersId != mLayersId) {
|
|
// Guard against bad data from hijacked child processes
|
|
NS_ERROR("Unexpected layers id in ContentReceivedInputBlock; dropping message...");
|
|
return;
|
|
}
|
|
if (GetApzcTreeManager()) {
|
|
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
|
|
GetApzcTreeManager(), &APZCTreeManager::ContentReceivedInputBlock,
|
|
aInputBlockId, aPreventDefault));
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::SetTargetAPZC(uint64_t aInputBlockId,
|
|
const nsTArray<ScrollableLayerGuid>& aTargets)
|
|
{
|
|
for (size_t i = 0; i < aTargets.Length(); i++) {
|
|
if (aTargets[i].mLayersId != mLayersId) {
|
|
// Guard against bad data from hijacked child processes
|
|
NS_ERROR("Unexpected layers id in SetTargetAPZC; dropping message...");
|
|
return;
|
|
}
|
|
}
|
|
if (GetApzcTreeManager()) {
|
|
// need a local var to disambiguate between the SetTargetAPZC overloads.
|
|
void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
|
|
= &APZCTreeManager::SetTargetAPZC;
|
|
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
|
|
GetApzcTreeManager(), setTargetApzcFunc,
|
|
aInputBlockId, aTargets));
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::SetAllowedTouchBehavior(uint64_t aInputBlockId,
|
|
const nsTArray<TouchBehaviorFlags>& aFlags)
|
|
{
|
|
if (GetApzcTreeManager()) {
|
|
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
|
|
GetApzcTreeManager(), &APZCTreeManager::SetAllowedTouchBehavior,
|
|
aInputBlockId, aFlags));
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::UpdateZoomConstraints(uint32_t aPresShellId,
|
|
ViewID aViewId,
|
|
const Maybe<ZoomConstraints>& aConstraints)
|
|
{
|
|
if (GetApzcTreeManager()) {
|
|
GetApzcTreeManager()->UpdateZoomConstraints(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
|
|
aConstraints);
|
|
}
|
|
}
|
|
|
|
bool
|
|
RenderFrameParent::HitTest(const nsRect& aRect)
|
|
{
|
|
return mTouchRegion.Contains(aRect);
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::StartScrollbarDrag(const AsyncDragMetrics& aDragMetrics)
|
|
{
|
|
if (GetApzcTreeManager()) {
|
|
uint64_t layersId = GetLayersId();
|
|
ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId,
|
|
aDragMetrics.mViewId);
|
|
|
|
APZThreadUtils::RunOnControllerThread(
|
|
NewRunnableMethod(GetApzcTreeManager(),
|
|
&APZCTreeManager::StartScrollbarDrag,
|
|
guid, aDragMetrics));
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier)
|
|
{
|
|
RefPtr<LayerManager> lm = mFrameLoader ? GetFrom(mFrameLoader) : nullptr;
|
|
// Perhaps the document containing this frame currently has no presentation?
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
*aTextureFactoryIdentifier =
|
|
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
|
|
} else {
|
|
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::TakeFocusForClick()
|
|
{
|
|
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
if (!fm) {
|
|
return;
|
|
}
|
|
nsCOMPtr<nsIContent> owner = mFrameLoader->GetOwnerContent();
|
|
if (!owner) {
|
|
return;
|
|
}
|
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(owner);
|
|
if (!element) {
|
|
return;
|
|
}
|
|
fm->SetFocus(element, nsIFocusManager::FLAG_BYMOUSE |
|
|
nsIFocusManager::FLAG_NOSCROLL);
|
|
}
|
|
|
|
} // namespace layout
|
|
} // namespace mozilla
|
|
|
|
nsDisplayRemote::nsDisplayRemote(nsDisplayListBuilder* aBuilder,
|
|
nsSubDocumentFrame* aFrame,
|
|
RenderFrameParent* aRemoteFrame)
|
|
: nsDisplayItem(aBuilder, aFrame)
|
|
, mRemoteFrame(aRemoteFrame)
|
|
, mEventRegionsOverride(EventRegionsOverride::NoOverride)
|
|
{
|
|
if (aBuilder->IsBuildingLayerEventRegions()) {
|
|
bool frameIsPointerEventsNone = !aFrame->PassPointerEventsToChildren()
|
|
&& (aFrame->StyleVisibility()->GetEffectivePointerEvents(aFrame) == NS_STYLE_POINTER_EVENTS_NONE);
|
|
if (aBuilder->IsInsidePointerEventsNoneDoc() || frameIsPointerEventsNone) {
|
|
mEventRegionsOverride |= EventRegionsOverride::ForceEmptyHitRegion;
|
|
}
|
|
if (nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(aFrame->PresContext()->PresShell())) {
|
|
mEventRegionsOverride |= EventRegionsOverride::ForceDispatchToContent;
|
|
}
|
|
}
|
|
}
|
|
|
|
already_AddRefed<Layer>
|
|
nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
LayerManager* aManager,
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
{
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
|
nsIntRect visibleRect = GetVisibleRect().ToNearestPixels(appUnitsPerDevPixel);
|
|
visibleRect += aContainerParameters.mOffset;
|
|
RefPtr<Layer> layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect, this, aContainerParameters);
|
|
if (layer && layer->AsContainerLayer()) {
|
|
layer->AsContainerLayer()->SetEventRegionsOverride(mEventRegionsOverride);
|
|
}
|
|
return layer.forget();
|
|
}
|
|
|
|
void
|
|
nsDisplayRemote::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
{
|
|
if (mRemoteFrame->HitTest(aRect)) {
|
|
aOutFrames->AppendElement(mFrame);
|
|
}
|
|
}
|
|
|