Bug 992521 - Part 4: Make PresShell events work when not in document, but contained by a ShadowRoot with a host in document. r=smaug

This commit is contained in:
William Chen 2014-06-07 01:42:54 -07:00
parent ed34839e51
commit 62bea1e104
2 changed files with 12 additions and 11 deletions

View File

@ -1440,7 +1440,7 @@ EventStateManager::FireContextClick()
}
}
nsIDocument* doc = mGestureDownContent->GetCurrentDoc();
nsIDocument* doc = mGestureDownContent->GetCrossShadowCurrentDoc();
AutoHandlingUserInputStatePusher userInpStatePusher(true, &event, doc);
// dispatch to DOM
@ -2752,7 +2752,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// NOTE: The newFocus isn't editable that also means it's not in
// designMode. In designMode, all contents are not focusable.
if (newFocus && !newFocus->IsEditable()) {
nsIDocument *doc = newFocus->GetCurrentDoc();
nsIDocument *doc = newFocus->GetCrossShadowCurrentDoc();
if (doc && newFocus == doc->GetRootElement()) {
nsIContent *bodyContent =
nsLayoutUtils::GetEditableRootContentByContentEditable(doc);
@ -4633,7 +4633,8 @@ EventStateManager::SetContentState(nsIContent* aContent, EventStates aState)
newHover = aContent;
} else {
NS_ASSERTION(!aContent ||
aContent->GetCurrentDoc() == mPresContext->PresShell()->GetDocument(),
aContent->GetCrossShadowCurrentDoc() ==
mPresContext->PresShell()->GetDocument(),
"Unexpected document");
nsIFrame *frame = aContent ? aContent->GetPrimaryFrame() : nullptr;
if (frame && nsLayoutUtils::IsViewportScrollbarFrame(frame)) {

View File

@ -6334,7 +6334,7 @@ nsIContent*
PresShell::GetCurrentEventContent()
{
if (mCurrentEventContent &&
mCurrentEventContent->GetCurrentDoc() != mDocument) {
mCurrentEventContent->GetCrossShadowCurrentDoc() != mDocument) {
mCurrentEventContent = nullptr;
mCurrentEventFrame = nullptr;
}
@ -6375,7 +6375,7 @@ PresShell::GetEventTargetContent(WidgetEvent* aEvent)
nsIFrame* currentEventFrame = GetCurrentEventFrame();
if (currentEventFrame) {
currentEventFrame->GetContentForEvent(aEvent, getter_AddRefs(content));
NS_ASSERTION(!content || content->GetCurrentDoc() == mDocument,
NS_ASSERTION(!content || content->GetCrossShadowCurrentDoc() == mDocument,
"handing out content from a different doc");
}
}
@ -6407,7 +6407,7 @@ PresShell::PopCurrentEventInfo()
// Don't use it if it has moved to a different document.
if (mCurrentEventContent &&
mCurrentEventContent->GetCurrentDoc() != mDocument) {
mCurrentEventContent->GetCrossShadowCurrentDoc() != mDocument) {
mCurrentEventContent = nullptr;
mCurrentEventFrame = nullptr;
}
@ -6877,7 +6877,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
} else if (capturingContent) {
// if the mouse is being captured then retarget the mouse event at the
// document that is being captured.
retargetEventDoc = capturingContent->GetCurrentDoc();
retargetEventDoc = capturingContent->GetCrossShadowCurrentDoc();
#ifdef ANDROID
} else if (aEvent->eventStructType == NS_TOUCH_EVENT) {
retargetEventDoc = GetTouchEventTargetDocument();
@ -6978,7 +6978,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
if (!captureRetarget) {
// A check was already done above to ensure that capturingContent is
// in this presshell.
NS_ASSERTION(capturingContent->GetCurrentDoc() == GetDocument(),
NS_ASSERTION(capturingContent->GetCrossShadowCurrentDoc() == GetDocument(),
"Unexpected document");
nsIFrame* captureFrame = capturingContent->GetPrimaryFrame();
if (captureFrame) {
@ -7127,7 +7127,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
capturingContent))) {
// A check was already done above to ensure that capturingContent is
// in this presshell.
NS_ASSERTION(capturingContent->GetCurrentDoc() == GetDocument(),
NS_ASSERTION(capturingContent->GetCrossShadowCurrentDoc() == GetDocument(),
"Unexpected document");
nsIFrame* capturingFrame = capturingContent->GetPrimaryFrame();
if (capturingFrame) {
@ -7468,12 +7468,12 @@ PresShell::HandleEventWithTarget(WidgetEvent* aEvent, nsIFrame* aFrame,
MOZ_ASSERT(!aFrame || aFrame->PresContext()->GetPresShell() == this,
"wrong shell");
if (aContent) {
nsIDocument* doc = aContent->GetCurrentDoc();
nsIDocument* doc = aContent->GetCrossShadowCurrentDoc();
NS_ASSERTION(doc, "event for content that isn't in a document");
NS_ASSERTION(!doc || doc->GetShell() == this, "wrong shell");
}
#endif
NS_ENSURE_STATE(!aContent || aContent->GetCurrentDoc() == mDocument);
NS_ENSURE_STATE(!aContent || aContent->GetCrossShadowCurrentDoc() == mDocument);
PushCurrentEventInfo(aFrame, aContent);
nsresult rv = HandleEventInternal(aEvent, aStatus);