Bug 1118169 - Support -moz-window-dragging:drag in HTML. r=mstange r=bz

This commit is contained in:
Paul Rouget 2015-02-02 15:10:51 -05:00
parent 2a844c3f32
commit 5acf19eeae
7 changed files with 55 additions and 5 deletions

View File

@ -842,6 +842,7 @@ nsDocShell::nsDocShell():
mInPrivateBrowsing(false),
mUseRemoteTabs(false),
mDeviceSizeIsPageSize(false),
mWindowDraggingAllowed(false),
mCanExecuteScripts(false),
mFiredUnloadEvent(false),
mEODForCurrentDocument(false),
@ -3013,6 +3014,35 @@ nsDocShell::AddProfileTimelineMarker(UniquePtr<TimelineMarker>& aMarker)
}
}
NS_IMETHODIMP
nsDocShell::SetWindowDraggingAllowed(bool aValue)
{
nsRefPtr<nsDocShell> parent = GetParentDocshell();
if (!aValue && mItemType == typeChrome && !parent) {
// Window dragging is always allowed for top level
// chrome docshells.
return NS_ERROR_FAILURE;
}
mWindowDraggingAllowed = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetWindowDraggingAllowed(bool* aValue)
{
// window dragging regions in CSS (-moz-window-drag:drag)
// can be slow. Default behavior is to only allow it for
// chrome top level windows.
nsRefPtr<nsDocShell> parent = GetParentDocshell();
if (mItemType == typeChrome && !parent) {
// Top level chrome window
*aValue = true;
} else {
*aValue = mWindowDraggingAllowed;
}
return NS_OK;
}
void
nsDocShell::ClearProfileTimelineMarkers()
{

View File

@ -885,6 +885,7 @@ protected:
bool mInPrivateBrowsing;
bool mUseRemoteTabs;
bool mDeviceSizeIsPageSize;
bool mWindowDraggingAllowed;
// Because scriptability depends on the mAllowJavascript values of our
// ancestors, we cache the effective scriptability and recompute it when

View File

@ -54,7 +54,7 @@ interface nsITabParent;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(e0e833fe-3a5b-48b0-8684-a097e09c0723)]
[scriptable, builtinclass, uuid(888fcf04-a69b-11e4-8d33-6fbb72d2eb03)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@ -1053,4 +1053,11 @@ interface nsIDocShell : nsIDocShellTreeItem
* Holds the id of the payment request associated with this docshell if any.
*/
attribute DOMString paymentRequestId;
/**
* Allow usage of -moz-window-dragging:drag for content docshells.
* True for top level chrome docshells. Throws if set to false with
* top level chrome docshell.
*/
attribute boolean windowDraggingAllowed;
};

View File

@ -587,7 +587,8 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mContainsPluginItem(false),
mAncestorHasTouchEventHandler(false),
mAncestorHasScrollEventHandler(false),
mHaveScrollableDisplayPort(false)
mHaveScrollableDisplayPort(false),
mWindowDraggingAllowed(false)
{
MOZ_COUNT_CTOR(nsDisplayListBuilder);
PL_InitArenaPool(&mPool, "displayListArena", 1024,
@ -1002,6 +1003,9 @@ nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame)
mFramesMarkedForDisplay.AppendElement(state->mCaretFrame);
MarkFrameForDisplay(state->mCaretFrame, nullptr);
}
nsPresContext* pc = aReferenceFrame->PresContext();
pc->GetDocShell()->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
}
void
@ -1010,8 +1014,14 @@ nsDisplayListBuilder::LeavePresShell(nsIFrame* aReferenceFrame)
NS_ASSERTION(CurrentPresShellState()->mPresShell ==
aReferenceFrame->PresContext()->PresShell(),
"Presshell mismatch");
ResetMarkedFramesForDisplayList();
mPresShellStates.SetLength(mPresShellStates.Length() - 1);
if (!mPresShellStates.IsEmpty()) {
nsPresContext* pc = CurrentPresContext();
pc->GetDocShell()->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
}
}
void
@ -1233,7 +1243,7 @@ nsDisplayListBuilder::RecomputeCurrentAnimatedGeometryRoot()
void
nsDisplayListBuilder::AdjustWindowDraggingRegion(nsIFrame* aFrame)
{
if (!IsForPainting() || IsInSubdocument()) {
if (!mWindowDraggingAllowed || !IsForPainting()) {
return;
}

View File

@ -907,6 +907,7 @@ private:
// display list has a display port. An async-scrollable scroll frame is one
// which WantsAsyncScroll().
bool mHaveScrollableDisplayPort;
bool mWindowDraggingAllowed;
};
class nsDisplayItem;

View File

@ -2061,6 +2061,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
aBuilder->SetLayerEventRegions(eventRegions);
set.BorderBackground()->AppendNewToTop(eventRegions);
}
aBuilder->AdjustWindowDraggingRegion(this);
BuildDisplayList(aBuilder, dirtyRect, set);
}
@ -2456,6 +2457,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
if (eventRegions) {
eventRegions->AddFrame(aBuilder, child);
}
aBuilder->AdjustWindowDraggingRegion(child);
child->BuildDisplayList(aBuilder, dirty, aLists);
aBuilder->DisplayCaret(child, dirty, aLists.Content());
#ifdef DEBUG
@ -2475,6 +2477,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
aBuilder->SetLayerEventRegions(eventRegions);
pseudoStack.BorderBackground()->AppendNewToTop(eventRegions);
}
aBuilder->AdjustWindowDraggingRegion(child);
child->BuildDisplayList(aBuilder, dirty, pseudoStack);
aBuilder->DisplayCaret(child, dirty, pseudoStack.Content());

View File

@ -1332,8 +1332,6 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
aBuilder->AddWindowExcludeGlassRegion(
nsRect(aBuilder->ToReferenceFrame(this), GetSize()));
}
aBuilder->AdjustWindowDraggingRegion(this);
}
nsDisplayListCollection tempLists;