Merge mozilla-central to tracemonkey.

This commit is contained in:
Robert Sayre 2010-01-04 08:56:05 -05:00
commit 898c18d7b4
82 changed files with 961 additions and 308 deletions

View File

@ -4463,7 +4463,7 @@ nsBrowserAccess.prototype = {
newWindow = content;
if (aURI) {
let referrer = aOpener ? makeURI(aOpener.location.href) : null;
gBrowser.loadURIWithFlag(aURI.spec, loadflags, referrer, null, null);
gBrowser.loadURIWithFlags(aURI.spec, loadflags, referrer, null, null);
}
if (!gPrefService.getBoolPref("browser.tabs.loadDivertedInBackground"))
content.focus();

View File

@ -102,6 +102,7 @@ _BROWSER_FILES = \
browser_bug495058.js \
browser_bug517902.js \
browser_bug521216.js \
browser_bug537474.js \
browser_discovery.js \
browser_tabfocus.js \
discovery.html \

View File

@ -0,0 +1,8 @@
function test() {
var currentWin = content;
var newWin =
browserDOMWindow.openURI(makeURI("about:"), null,
Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW, null)
is(newWin, currentWin, "page loads in the current content window");
gBrowser.stop();
}

View File

@ -210,6 +210,9 @@ function next_test() {
}
function run_test() {
// XXX disabled due to bug 510219
return;
// Clean up database from all bookmarks.
remove_all_bookmarks();

View File

@ -865,8 +865,8 @@ public:
*/
nsIFrame* GetPrimaryFrame() const { return mPrimaryFrame; }
void SetPrimaryFrame(nsIFrame* aFrame) {
NS_WARN_IF_FALSE(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
mPrimaryFrame = aFrame;
}

View File

@ -13,10 +13,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=421640
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396392">Mozilla Bug Range getClientRects and getBoundingClientRect</a>
<div id="content" style="font-face:monospace;font-size:12px;width:100px">
<p>000000<span>0</span></p><div>00000<span>0</span></div><p>0000<span>0000</span>0000</p>
<div id="content" style="font-family:monospace;font-size:12px;width:100px">
<p>000000<span>0</span></p><div>00000<span>0</span></div><p>0000<span>0000</span>0000</p><div><span>000000000000 00000000000000 000000</span></div><div>000000000000 00000000000003 100305</div>
</div>
<div id="mixeddir" style="font-face:monospace;font-size:12px;width:100px"><span>english <bdo dir="rtl">rtl-overide english</bdo> word</span></div>
<div id="mixeddir" style="font-family:monospace;font-size:12px;width:100px"><span>english <bdo id="bdo" dir="rtl">rtl-overide english</bdo> word</span></div>
<div id="mixeddir2" style="font-family:monospace;font-size:12px"><span>english <bdo id="bdo2" dir="rtl">rtl-override english</bdo> word</span></div>
<pre id="test">
<script class="testbody" type="text/javascript">
@ -36,13 +37,20 @@ function isEmptyRectList(rectlist, name) {
is(rectlist.length, 0, name + 'empty rectlist should have zero rects');
}
// round coordinates to the nearest 1/256 of a pixel
function roundCoord(x) {
return Math.round(x * 256) / 256;
}
function _getRect(r) {
if (r.length) //array
return "{left:"+r[0]+",right:"+r[1]+",top:"+r[2]+",bottom:"+r[3]
+",width:"+r[4]+",height:"+r[5]+"}";
return "{left:"+roundCoord(r[0])+",right:"+roundCoord(r[1])+
",top:" +roundCoord(r[2])+",bottom:"+roundCoord(r[3])+
",width:"+roundCoord(r[4])+",height:"+roundCoord(r[5])+"}";
else
return "{left:"+r.left+",right:"+r.right+",top:"+r.top+",bottom:"
+r.bottom+",width:"+r.width+",height:"+r.height+"}";
return "{left:"+roundCoord(r.left)+",right:"+roundCoord(r.right)+
",top:"+roundCoord(r.top)+",bottom:"+roundCoord(r.bottom)+
",width:"+roundCoord(r.width)+",height:"+roundCoord(r.height)+"}";
}
function runATest(obj) {
@ -90,13 +98,18 @@ function doTest(){
var root = document.getElementById('content');
var firstP = root.firstElementChild, spanInFirstP = firstP.childNodes[1],
firstDiv = root.childNodes[2], spanInFirstDiv = firstDiv.childNodes[1],
secondP = root.childNodes[3], spanInSecondP = secondP.childNodes[1];
secondP = root.childNodes[3], spanInSecondP = secondP.childNodes[1],
secondDiv = root.childNodes[4], spanInSecondDiv = secondDiv.firstChild,
thirdDiv = root.childNodes[5];
var firstPRect = firstP.getBoundingClientRect(),
spanInFirstPRect = spanInFirstP.getBoundingClientRect(),
firstDivRect = firstDiv.getBoundingClientRect(),
spanInFirstDivRect = spanInFirstDiv.getBoundingClientRect(),
secondPRect = secondP.getBoundingClientRect(),
spanInSecondPRect = spanInSecondP.getBoundingClientRect();
secondDivRect = secondDiv.getBoundingClientRect(),
spanInSecondPRect = spanInSecondP.getBoundingClientRect(),
spanInSecondDivRect = spanInSecondDiv.getBoundingClientRect(),
spanInSecondDivRectList = spanInSecondDiv.getClientRects();
var widthPerchar = spanInSecondPRect.width / spanInSecondP.firstChild.length;
var testcases = [
{name:'nodesNotInDocument', range:[document.createTextNode('abc'), 1],
@ -150,6 +163,62 @@ function doTest(){
spanInSecondPRect.height]]}
];
testcases.forEach(runATest);
// testcases that have different ranges in LTR and RTL
var directionDependentTestcases;
if (isLTR) {
directionDependentTestcases = [
{name:'spanAcrossLines',range:[spanInSecondDiv.firstChild, 1, spanInSecondDiv.firstChild, 30],
rect: spanInSecondDivRect,
rectList:[[spanInSecondDivRectList[0].left+widthPerchar,
spanInSecondDivRectList[0].right, spanInSecondDivRectList[0].top,
spanInSecondDivRectList[0].bottom, spanInSecondDivRectList[0].width - widthPerchar,
spanInSecondDivRectList[0].height],
spanInSecondDivRectList[1],
[spanInSecondDivRectList[2].left,
spanInSecondDivRectList[2].right - 4 * widthPerchar, spanInSecondDivRectList[2].top,
spanInSecondDivRectList[2].bottom,
spanInSecondDivRectList[2].width - 4 * widthPerchar,
spanInSecondDivRectList[2].height]]},
{name:'textAcrossLines',range:[thirdDiv.firstChild, 13, thirdDiv.firstChild, 28],
rect: [spanInSecondDivRectList[1].left, spanInSecondDivRectList[1].right,
spanInSecondDivRectList[1].top + secondDivRect.height,
spanInSecondDivRectList[1].bottom + secondDivRect.height,
spanInSecondDivRectList[1].width, spanInSecondDivRectList[1].height]}
];
} else {
directionDependentTestcases = [
{name:'spanAcrossLines',range:[spanInSecondDiv.firstChild, 1, spanInSecondDiv.firstChild, 30],
rect: spanInSecondDivRect,
rectList:[[spanInSecondDivRectList[0].left+widthPerchar,
spanInSecondDivRectList[0].right, spanInSecondDivRectList[0].top,
spanInSecondDivRectList[0].bottom, spanInSecondDivRectList[0].width - widthPerchar,
spanInSecondDivRectList[0].height],
spanInSecondDivRectList[1],
spanInSecondDivRectList[2],
spanInSecondDivRectList[3],
[spanInSecondDivRectList[4].left,
spanInSecondDivRectList[4].right - 4 * widthPerchar,
spanInSecondDivRectList[4].top,
spanInSecondDivRectList[4].bottom,
spanInSecondDivRectList[4].width - 4 * widthPerchar,
spanInSecondDivRectList[4].height]]},
{name:'textAcrossLines',range:[thirdDiv.firstChild, 13, thirdDiv.firstChild, 28],
rect: [spanInSecondDivRectList[2].left, spanInSecondDivRectList[2].right,
spanInSecondDivRectList[2].top + secondDivRect.height,
spanInSecondDivRectList[2].bottom + secondDivRect.height,
spanInSecondDivRectList[2].width, spanInSecondDivRectList[2].height],
rectList:[[spanInSecondDivRectList[2].left, spanInSecondDivRectList[2].right,
spanInSecondDivRectList[2].top + secondDivRect.height,
spanInSecondDivRectList[2].bottom + secondDivRect.height,
spanInSecondDivRectList[2].width, spanInSecondDivRectList[2].height],
[spanInSecondDivRectList[2].left, spanInSecondDivRectList[2].left,
spanInSecondDivRectList[2].top + secondDivRect.height,
spanInSecondDivRectList[2].bottom + secondDivRect.height,
0, spanInSecondDivRectList[2].height]]}
];
}
directionDependentTestcases.forEach(runATest);
}
function testMixedDir(){
var root = document.getElementById('mixeddir');
@ -157,6 +226,28 @@ function testMixedDir(){
firstSpanRectList = firstSpan.getClientRects();
runATest({name:'mixeddir',range:[firstSpan.firstChild,0,firstSpan.lastChild,firstSpan.lastChild.length],
rect: firstSpanRect, rectList:firstSpanRectList});
root = document.getElementById('mixeddir2');
firstSpan = root.firstElementChild;
firstSpanRect = firstSpan.getBoundingClientRect();
bdo = document.getElementById('bdo2');
bdoRect=bdo.getBoundingClientRect();
var widthPerChar = bdoRect.width / bdo.firstChild.length;
runATest({name:'mixeddirPartial', range:[firstSpan.firstChild, 3,
bdo.firstChild, 7],
rect: [firstSpanRect.left + 3*widthPerChar, bdoRect.right,
bdoRect.top, bdoRect.bottom,
(firstSpan.firstChild.length + bdo.firstChild.length - 3) *
widthPerChar,
bdoRect.height],
rectList:[[firstSpanRect.left + 3*widthPerChar,
bdoRect.left,
firstSpanRect.top, firstSpanRect.bottom,
(firstSpan.firstChild.length - 3) * widthPerChar,
firstSpanRect.height],
[bdoRect.right - 7 * widthPerChar, bdoRect.right,
bdoRect.top, bdoRect.bottom,
7*widthPerChar, bdoRect.height]]});
}
function test(){
//test ltr

View File

@ -0,0 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<body onload="document.getElementById('v').appendChild(document.getElementById('s'));">
<style id="s">div:first-letter { float: right; } </style><div id="v"><span>AB</span></div>
</body>
</html>

View File

@ -0,0 +1,37 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="qwe">
<content>
<xul:label style="-moz-binding: url(#xar)" xbl:inherits="xbl:text=label" flex="1"/>
</content>
</binding>
<binding id="xar">
<content>
<html:table><children/></html:table>
</content>
</binding>
</bindings>
<script type="text/javascript">
function boom()
{
document.getElementById("b").setAttribute('label', "1 2 3");
document.documentElement.offsetHeight;
document.getElementById("b").removeAttribute('label');
}
</script>
</head>
<body onload="boom();">
<div style="width: 0px;"><box id="b" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" style="-moz-binding: url(#qwe);"/></div>
</body>
</html>

View File

@ -0,0 +1,14 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="td"><content><html:div><children/></html:div></content></binding>
</bindings>
<style type="text/css">
div, tbody { position: absolute; }
div:first-letter { }
</style>
</head>
<body>
<div><table>A<tbody><tr style="-moz-binding: url(#td);"></tr></tbody>B</table></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body onload="document.body.appendChild(document.createElementNS('http://www.w3.org/1999/xhtml', 'span'));" style="-moz-binding: url('537141.xml#mo');">
<g xmlns="http://www.w3.org/2000/svg"/></body>
</html>

View File

@ -0,0 +1,2 @@
<!-- This has to be a separate file to trigger the bug -->
<bindings xmlns="http://www.mozilla.org/xbl"><binding id="mo"><content><mrow xmlns="http://www.w3.org/1998/Math/MathML"><children xmlns="http://www.mozilla.org/xbl"/></mrow></content></binding></bindings>

View File

@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml" id="a">
<head>
<style>
#a { -moz-column-count: 2; }
#a:first-letter { }
</style>
</head>
<body id="b" onload="document.getElementById('b').appendChild(document.createElement('tr'));"></body>
X
</html>

View File

@ -262,9 +262,14 @@ load 492163-1.xhtml
load 495350-1.html
load 497519-1.xhtml
load 497519-2.xhtml
load 499841-1.xhtml
load 500467-1.html
load 501878-1.html
load 503936-1.html
load 526378-1.xul
load 535721-1.xhtml
load 535911-1.xhtml
load 536623-1.xhtml
load 537059-1.xhtml
load 537141-1.xhtml
load 537562-1.xhtml

View File

@ -513,14 +513,17 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
}
lineIter.GetLine()->MarkDirty();
nsIFrame* nextBidi;
PRInt32 runEnd = contentOffset + runLength;
EnsureBidiContinuation(frame, &nextBidi, frameIndex,
contentOffset,
contentOffset + runLength);
runEnd);
if (NS_FAILED(mSuccess)) {
break;
}
nextBidi->AdjustOffsetsForBidi(runEnd,
contentOffset + fragmentLength);
frame = nextBidi;
contentOffset += runLength;
contentOffset = runEnd;
} // if (runLength < fragmentLength)
else {
if (contentOffset + fragmentLength == contentTextLength) {

View File

@ -1362,6 +1362,9 @@ MoveChildrenTo(nsPresContext* aPresContext,
//----------------------------------------------------------------------
NS_IMPL_ADDREF(nsCSSFrameConstructor)
NS_IMPL_RELEASE(nsCSSFrameConstructor)
nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument,
nsIPresShell *aPresShell)
: mDocument(aDocument)
@ -1378,6 +1381,8 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument,
, mIsDestroyingFrameTree(PR_FALSE)
, mRebuildAllStyleData(PR_FALSE)
, mHasRootAbsPosContainingBlock(PR_FALSE)
, mObservingRefreshDriver(PR_FALSE)
, mInStyleRefresh(PR_FALSE)
, mHoverGeneration(0)
, mRebuildAllExtraHint(nsChangeHint(0))
{
@ -2161,6 +2166,8 @@ static PRBool
NeedFrameFor(nsIFrame* aParentFrame,
nsIContent* aChildContent)
{
NS_PRECONDITION(!aChildContent->GetPrimaryFrame(), "Why did we get called?");
// don't create a whitespace frame if aParentFrame doesn't want it.
// always create frames for children in generated content. counter(),
// quotes, and attr() content can easily change dynamically and we don't
@ -3694,6 +3701,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
const nsStyleDisplay* display = styleContext->GetStyleDisplay();
nsIFrame* newFrame;
nsIFrame* primaryFrame;
if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
nsresult rv =
(this->*(data->mFullConstructor))(aState, aItem, aParentFrame,
@ -3701,6 +3709,8 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
if (NS_FAILED(rv)) {
return rv;
}
primaryFrame = newFrame;
} else {
nsIContent* const content = aItem.mContent;
@ -3731,8 +3741,6 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
display->IsScrollableOverflow()) {
BuildScrollFrame(aState, content, styleContext, newFrame,
geometricParent, frameToAddToList);
// No need to set the primary frame, since BuildScrollFrame did it already
bits |= FCDATA_SKIP_FRAMESET;
} else {
rv = InitAndRestoreFrame(aState, content, geometricParent, nsnull,
newFrame);
@ -3743,6 +3751,12 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
frameToAddToList = newFrame;
}
// Use frameToAddToList as the primary frame. In the non-scrollframe case
// they're equal, but in the scrollframe case newFrame is the scrolled
// frame, while frameToAddToList is the scrollframe (and should be the
// primary frame).
primaryFrame = frameToAddToList;
rv = aState.AddChild(frameToAddToList, aFrameItems, content, styleContext,
aParentFrame, allowOutOfFlow, allowOutOfFlow, isPopup);
if (NS_FAILED(rv)) {
@ -3839,7 +3853,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
"Incorrectly set FCDATA_IS_LINE_PARTICIPANT bits");
if (!(bits & FCDATA_SKIP_FRAMESET)) {
aItem.mContent->SetPrimaryFrame(newFrame);
aItem.mContent->SetPrimaryFrame(primaryFrame);
}
return NS_OK;
@ -4315,11 +4329,7 @@ nsCSSFrameConstructor::BuildScrollFrame(nsFrameConstructorState& aState,
InitAndRestoreFrame(aState, aContent, aNewFrame, nsnull, aScrolledFrame);
FinishBuildingScrollFrame(aNewFrame, aScrolledFrame);
// now set the primary frame to the ScrollFrame
aContent->SetPrimaryFrame(aNewFrame);
return NS_OK;
}
const nsCSSFrameConstructor::FrameConstructionData*
@ -6289,9 +6299,11 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
}
nsIAtom* frameType = parentFrame->GetType();
PRBool haveNoXBLChildren =
mDocument->BindingManager()->GetXBLChildNodesFor(aContainer) == nsnull;
FrameConstructionItemList items;
if (aNewIndexInContainer > 0 && GetParentType(frameType) == eTypeBlock) {
if (aNewIndexInContainer > 0 && GetParentType(frameType) == eTypeBlock &&
haveNoXBLChildren) {
// If there's a text node in the normal content list just before the new
// items, and it has no frame, make a frame construction item for it. If it
// doesn't need a frame, ConstructFramesFromItemList below won't give it
@ -6342,8 +6354,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
// To suppress whitespace-only text frames, we have to verify that
// our container's DOM child list matches its flattened tree child list.
// This is guaranteed to be true if GetXBLChildNodesFor() returns null.
items.SetParentHasNoXBLChildren(
!mDocument->BindingManager()->GetXBLChildNodesFor(aContainer));
items.SetParentHasNoXBLChildren(haveNoXBLChildren);
nsFrameItems frameItems;
ConstructFramesFromItemList(state, items, parentFrame, frameItems);
@ -6670,7 +6681,9 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
FrameConstructionItemList items;
ParentType parentType = GetParentType(frameType);
if (aIndexInContainer > 0 && parentType == eTypeBlock) {
PRBool haveNoXBLChildren =
mDocument->BindingManager()->GetXBLChildNodesFor(aContainer) == nsnull;
if (aIndexInContainer > 0 && parentType == eTypeBlock && haveNoXBLChildren) {
// If there's a text node in the normal content list just before the
// new node, and it has no frame, make a frame construction item for
// it, because it might need a frame now. No need to do this if our
@ -6683,7 +6696,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
AddFrameConstructionItems(state, aChild, aIndexInContainer, parentFrame, items);
if (aIndexInContainer + 1 < PRInt32(aContainer->GetChildCount()) &&
parentType == eTypeBlock) {
parentType == eTypeBlock && haveNoXBLChildren) {
// If there's a text node in the normal content list just after the
// new node, and it has no frame, make a frame construction item for
// it, because it might need a frame now. No need to do this if our
@ -6972,7 +6985,13 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// Examine the containing-block for the removed content and see if
// :first-letter style applies.
nsIFrame* containingBlock = GetFloatContainingBlock(parentFrame);
nsIFrame* inflowChild = childFrame;
if (childFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
inflowChild = frameManager->GetPlaceholderFrameFor(childFrame);
NS_ASSERTION(inflowChild, "No placeholder for out-of-flow?");
}
nsIFrame* containingBlock =
GetFloatContainingBlock(inflowChild->GetParent());
PRBool haveFLS = containingBlock && HasFirstLetterStyle(containingBlock);
if (haveFLS) {
// Trap out to special routine that handles adjusting a blocks
@ -7044,11 +7063,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
}
if (haveFLS && mRootElementFrame) {
NS_ASSERTION(containingBlock == GetFloatContainingBlock(parentFrame),
"What happened here?");
nsFrameConstructorState state(mPresShell, mFixedContainingBlock,
GetAbsoluteContainingBlock(parentFrame),
containingBlock);
RecoverLetterFrames(containingBlock);
}
@ -7401,9 +7415,6 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
frame->CharacterDataChanged(aInfo);
if (haveFirstLetterStyle) {
nsFrameConstructorState state(mPresShell, mFixedContainingBlock,
GetAbsoluteContainingBlock(frame),
block, nsnull);
RecoverLetterFrames(block);
}
}
@ -7798,8 +7809,12 @@ nsCSSFrameConstructor::WillDestroyFrameTree()
mQuoteList.Clear();
mCounterManager.Clear();
// Cancel all pending re-resolves
mRestyleEvent.Revoke();
// Remove ourselves as a refresh observer, so the refresh driver
// won't assert about us. But leave mObservingRefreshDriver true so
// we don't readd to it even if someone tries to post restyle events
// on us from this point on for some reason.
mPresShell->GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(this, Flush_Style);
}
//STATIC
@ -9596,10 +9611,17 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIFrame* aBlockFrame,
textSC = mPresShell->StyleSet()->ResolveStyleForNonElement(sc);
// Create a new text frame (the original one will be discarded)
// pass a temporary stylecontext, the correct one will be set later
// pass a temporary stylecontext, the correct one will be set
// later. Start off by unsetting the primary frame for
// aTextContent, so it's no longer pointing to the to-be-destroyed
// frame.
// XXXbz it would be really nice to destroy the old frame _first_,
// then create the new one, so we could avoid this hack.
aTextContent->SetPrimaryFrame(nsnull);
nsIFrame* textFrame = NS_NewTextFrame(mPresShell, textSC);
NS_ASSERTION(aBlockFrame == GetFloatContainingBlock(aParentFrame),
NS_ASSERTION(aBlockFrame == GetFloatContainingBlock(aParentFrame)->
GetFirstContinuation(),
"Containing block is confused");
nsFrameConstructorState state(mPresShell, mFixedContainingBlock,
GetAbsoluteContainingBlock(aParentFrame),
@ -9630,6 +9652,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIFrame* aBlockFrame,
SetInitialSingleChild(letterFrame, textFrame);
aResult.Clear();
aResult.AddChild(letterFrame);
NS_ASSERTION(!aBlockFrame->GetPrevContinuation(),
"should have the first continuation here");
aBlockFrame->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
}
}
@ -9811,7 +9835,6 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
return NS_ERROR_OUT_OF_MEMORY;;
}
newTextFrame->Init(textContent, parentFrame, nsnull);
textContent->SetPrimaryFrame(newTextFrame);
// Destroy the old text frame's continuations (the old text frame
// will be destroyed when its letter frame is destroyed).
@ -9833,6 +9856,10 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
// Remove placeholder frame and the float
aFrameManager->RemoveFrame(nsnull, placeholderFrame);
// Now that the old frames are gone, we can start pointing to our
// new primary frame.
textContent->SetPrimaryFrame(newTextFrame);
// Insert text frame in its place
nsFrameList textList(newTextFrame, newTextFrame);
aFrameManager->InsertFrames(parentFrame, nsnull, prevSibling, textList);
@ -9845,6 +9872,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext,
nsIPresShell* aPresShell,
nsFrameManager* aFrameManager,
nsIFrame* aFrame,
nsIFrame* aBlockFrame,
PRBool* aStopLooking)
{
nsIFrame* prevSibling = nsnull;
@ -9874,23 +9902,28 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext,
}
textFrame = NS_NewTextFrame(aPresShell, newSC);
textFrame->Init(textContent, aFrame, nsnull);
textContent->SetPrimaryFrame(textFrame);
// Next rip out the kid and replace it with the text frame
aFrameManager->RemoveFrame(nsnull, kid);
// Now that the old frames are gone, we can start pointing to our
// new primary frame.
textContent->SetPrimaryFrame(textFrame);
// Insert text frame in its place
nsFrameList textList(textFrame, textFrame);
aFrameManager->InsertFrames(aFrame, nsnull, prevSibling, textList);
*aStopLooking = PR_TRUE;
aFrame->RemoveStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
NS_ASSERTION(!aBlockFrame->GetPrevContinuation(),
"should have the first continuation here");
aBlockFrame->RemoveStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
break;
}
else if (IsInlineFrame(kid)) {
// Look inside child inline frame for the letter frame
RemoveFirstLetterFrames(aPresContext, aPresShell, aFrameManager, kid,
aStopLooking);
RemoveFirstLetterFrames(aPresContext, aPresShell, aFrameManager,
kid, aBlockFrame, aStopLooking);
if (*aStopLooking) {
break;
}
@ -9909,22 +9942,23 @@ nsCSSFrameConstructor::RemoveLetterFrames(nsPresContext* aPresContext,
nsIFrame* aBlockFrame)
{
aBlockFrame = aBlockFrame->GetFirstContinuation();
nsIFrame* continuation = aBlockFrame;
PRBool stopLooking = PR_FALSE;
nsresult rv;
do {
rv = RemoveFloatingFirstLetterFrames(aPresContext, aPresShell,
aFrameManager,
aBlockFrame, &stopLooking);
continuation, &stopLooking);
if (NS_SUCCEEDED(rv) && !stopLooking) {
rv = RemoveFirstLetterFrames(aPresContext, aPresShell, aFrameManager,
aBlockFrame, &stopLooking);
continuation, aBlockFrame, &stopLooking);
}
if (stopLooking) {
break;
}
aBlockFrame = aBlockFrame->GetNextContinuation();
} while (aBlockFrame);
continuation = continuation->GetNextContinuation();
} while (continuation);
return rv;
}
@ -9933,7 +9967,8 @@ nsresult
nsCSSFrameConstructor::RecoverLetterFrames(nsIFrame* aBlockFrame)
{
aBlockFrame = aBlockFrame->GetFirstContinuation();
nsIFrame* continuation = aBlockFrame;
nsIFrame* parentFrame = nsnull;
nsIFrame* textFrame = nsnull;
nsIFrame* prevFrame = nsnull;
@ -9942,9 +9977,9 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsIFrame* aBlockFrame)
nsresult rv;
do {
// XXX shouldn't this bit be set already (bug 408493), assert instead?
aBlockFrame->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_STYLE);
rv = WrapFramesInFirstLetterFrame(aBlockFrame, aBlockFrame,
aBlockFrame->GetFirstChild(nsnull),
continuation->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_STYLE);
rv = WrapFramesInFirstLetterFrame(aBlockFrame, continuation,
continuation->GetFirstChild(nsnull),
&parentFrame, &textFrame, &prevFrame,
letterFrames, &stopLooking);
if (NS_FAILED(rv)) {
@ -9953,8 +9988,8 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsIFrame* aBlockFrame)
if (stopLooking) {
break;
}
aBlockFrame = aBlockFrame->GetNextContinuation();
} while (aBlockFrame);
continuation = continuation->GetNextContinuation();
} while (continuation);
if (parentFrame) {
// Take the old textFrame out of the parents child list
@ -11023,8 +11058,6 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint)
if (!mPresShell || !mPresShell->GetRootFrame())
return;
nsAutoScriptBlocker scriptBlocker;
// Make sure that the viewmanager will outlive the presshell
nsIViewManager::UpdateViewBatch batch(mPresShell->GetViewManager());
@ -11032,6 +11065,12 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint)
// the parent frame and thus destroys the pres shell.
nsCOMPtr<nsIPresShell> kungFuDeathGrip(mPresShell);
// We may reconstruct frames below and hence process anything that is in the
// tree. We don't want to get notified to process those items again after.
mPresShell->GetDocument()->FlushPendingNotifications(Flush_ContentAndNotify);
nsAutoScriptBlocker scriptBlocker;
// Tell the style set to get the old rule tree out of the way
// so we can recalculate while maintaining rule tree immutability
nsresult rv = mPresShell->StyleSet()->BeginReconstruct();
@ -11120,6 +11159,9 @@ nsCSSFrameConstructor::ProcessPendingRestyles()
// Process non-animation restyles...
ProcessPendingRestyleTable(mPendingRestyles);
NS_POSTCONDITION(mPendingRestyles.Count() == 0,
"We should have processed mPendingRestyles to completion");
// ...and then process animation restyles. This needs to happen
// second because we need to start animations that resulted from the
// first set of restyles (e.g., CSS transitions with negative
@ -11133,9 +11175,19 @@ nsCSSFrameConstructor::ProcessPendingRestyles()
ProcessPendingRestyleTable(mPendingAnimationRestyles);
presContext->SetProcessingAnimationStyleChange(PR_FALSE);
mInStyleRefresh = PR_FALSE;
NS_POSTCONDITION(mPendingAnimationRestyles.Count() == 0,
"We should have processed mPendingAnimationRestyles to "
"completion");
NS_POSTCONDITION(mPendingRestyles.Count() == 0,
"We should not have posted new non-animation restyles while "
"processing animation restyles");
if (mRebuildAllStyleData) {
// We probably wasted a lot of work up above, but this seems safest
// and it should be rarely used.
// This might add us as a refresh observer again; that's ok.
RebuildAllStyleData(nsChangeHint(0));
}
}
@ -11178,17 +11230,29 @@ nsCSSFrameConstructor::PostRestyleEventCommon(nsIContent* aContent,
void
nsCSSFrameConstructor::PostRestyleEventInternal()
{
if (!mRestyleEvent.IsPending()) {
nsRefPtr<RestyleEvent> ev = new RestyleEvent(this);
if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
NS_WARNING("failed to dispatch restyle event");
// XXXbz and what?
} else {
mRestyleEvent = ev;
}
// Make sure we're not in a style refresh; if we are, we still have
// a call to ProcessPendingRestyles coming and there's no need to
// add ourselves as a refresh observer until then.
if (!mInStyleRefresh && !mObservingRefreshDriver) {
mObservingRefreshDriver = mPresShell->GetPresContext()->
RefreshDriver()->AddRefreshObserver(this, Flush_Style);
}
}
void
nsCSSFrameConstructor::WillRefresh(mozilla::TimeStamp aTime)
{
NS_ASSERTION(mObservingRefreshDriver, "How did we get here?");
// Stop observing the refresh driver and flag ourselves as being in
// a refresh so we don't restart due to animation-triggered
// restyles. The actual work of processing our restyles will get
// done when the refresh driver flushes styles.
mPresShell->GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(this, Flush_Style);
mObservingRefreshDriver = PR_FALSE;
mInStyleRefresh = PR_TRUE;
}
void
nsCSSFrameConstructor::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint)
{
@ -11202,18 +11266,6 @@ nsCSSFrameConstructor::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint)
PostRestyleEventInternal();
}
NS_IMETHODIMP nsCSSFrameConstructor::RestyleEvent::Run()
{
if (!mConstructor)
return NS_OK; // event was revoked
// Make sure that any restyles that happen from now on will go into
// a new event.
mConstructor->mRestyleEvent.Forget();
return mConstructor->mPresShell->FlushPendingNotifications(Flush_Style);
}
NS_IMETHODIMP
nsCSSFrameConstructor::LazyGenerateChildrenEvent::Run()
{
@ -11279,6 +11331,7 @@ nsCSSFrameConstructor::LazyGenerateChildrenEvent::Run()
PRBool
nsCSSFrameConstructor::FrameConstructionItem::IsWhitespace() const
{
NS_PRECONDITION(!mContent->GetPrimaryFrame(), "How did that happen?");
if (!mIsText) {
return PR_FALSE;
}

View File

@ -53,6 +53,7 @@
#include "nsThreadUtils.h"
#include "nsPageContentFrame.h"
#include "nsCSSPseudoElements.h"
#include "nsRefreshDriver.h"
class nsIDocument;
struct nsFrameItems;
@ -78,7 +79,7 @@ typedef void (nsLazyFrameConstructionCallback)
class nsFrameConstructorState;
class nsFrameConstructorSaveState;
class nsCSSFrameConstructor
class nsCSSFrameConstructor : public nsARefreshObserver
{
public:
nsCSSFrameConstructor(nsIDocument *aDocument, nsIPresShell* aPresShell);
@ -86,6 +87,15 @@ public:
NS_ASSERTION(mUpdateCount == 0, "Dying in the middle of our own update?");
}
// Matches signature on nsARefreshObserver. Just like
// NS_DECL_ISUPPORTS, but without the QI part.
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
protected:
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
public:
struct RestyleData;
friend struct RestyleData;
@ -236,6 +246,9 @@ public:
{
PostRestyleEventCommon(aContent, aRestyleHint, aMinChangeHint, PR_TRUE);
}
// nsARefreshObserver
virtual void WillRefresh(mozilla::TimeStamp aTime);
private:
/**
* Notify the frame constructor that a content node needs to have its
@ -594,9 +607,7 @@ private:
set. */
#define FCDATA_SUPPRESS_FRAME 0x40
/* If FCDATA_MAY_NEED_SCROLLFRAME is set, the new frame should be wrapped in
a scrollframe if its overflow type so requires. This flag might override
FCDATA_SKIP_FRAMEMAP, since scrollframe construction will add to the frame
map. */
a scrollframe if its overflow type so requires. */
#define FCDATA_MAY_NEED_SCROLLFRAME 0x80
#ifdef MOZ_XUL
/* If FCDATA_IS_POPUP is set, the new frame is a XUL popup frame. These need
@ -1331,7 +1342,6 @@ private:
// Build a scroll frame:
// Calls BeginBuildingScrollFrame, InitAndRestoreFrame, and then FinishBuildingScrollFrame.
// Sets the primary frame for the content to the output aNewFrame.
// @param aNewFrame the created scrollframe --- output only
// @param aParentFrame the geometric parent that the scrollframe will have.
nsresult
@ -1558,6 +1568,7 @@ private:
nsIPresShell* aPresShell,
nsFrameManager* aFrameManager,
nsIFrame* aFrame,
nsIFrame* aBlockFrame,
PRBool* aStopLooking);
// Special remove method for those pesky floating first-letter frames
@ -1671,21 +1682,6 @@ public:
nsCOMPtr<nsIContent> mContent;
};
class RestyleEvent;
friend class RestyleEvent;
class RestyleEvent : public nsRunnable {
public:
NS_DECL_NSIRUNNABLE
RestyleEvent(nsCSSFrameConstructor *aConstructor)
: mConstructor(aConstructor) {
NS_PRECONDITION(aConstructor, "Must have a constructor!");
}
void Revoke() { mConstructor = nsnull; }
private:
nsCSSFrameConstructor *mConstructor;
};
friend class nsFrameConstructorState;
private:
@ -1738,11 +1734,13 @@ private:
PRPackedBool mRebuildAllStyleData : 1;
// This is true if mDocElementContainingBlock supports absolute positioning
PRPackedBool mHasRootAbsPosContainingBlock : 1;
// True if we're already waiting for a refresh notification
PRPackedBool mObservingRefreshDriver : 1;
// True if we're in the middle of a nsRefreshDriver refresh
PRPackedBool mInStyleRefresh : 1;
PRUint32 mHoverGeneration;
nsChangeHint mRebuildAllExtraHint;
nsRevocableEventPtr<RestyleEvent> mRestyleEvent;
nsCOMPtr<nsILayoutHistoryState> mTempFrameTreeState;
nsDataHashtable<nsISupportsHashKey, RestyleData> mPendingRestyles;

View File

@ -936,7 +936,7 @@ protected:
nsIDocument* mDocument; // [STRONG]
nsPresContext* mPresContext; // [STRONG]
nsStyleSet* mStyleSet; // [OWNS]
nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
nsCSSFrameConstructor* mFrameConstructor; // [STRONG]
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
nsFrameSelection* mSelection;
nsFrameManagerBase mFrameManager; // [OWNS]

View File

@ -1553,7 +1553,7 @@ PresShell::~PresShell()
#endif
delete mStyleSet;
delete mFrameConstructor;
NS_IF_RELEASE(mFrameConstructor);
mCurrentEventContent = nsnull;
@ -1600,6 +1600,7 @@ PresShell::Init(nsIDocument* aDocument,
// Create our frame constructor.
mFrameConstructor = new nsCSSFrameConstructor(mDocument, this);
NS_ENSURE_TRUE(mFrameConstructor, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(mFrameConstructor);
// The document viewer owns both view manager and pres shell.
mViewManager->SetViewObserver(this);
@ -2649,6 +2650,10 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
{
nsIViewManager::UpdateViewBatch batch(mViewManager);
// Have to make sure that the content notifications are flushed before we
// start messing with the frame model; otherwise we can get content doubling.
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
// Make sure style is up to date
{
nsAutoScriptBlocker scriptBlocker;
@ -4374,21 +4379,8 @@ PresShell::ClearMouseCapture(nsIView* aView)
if (gCaptureInfo.mContent) {
if (aView) {
// if a view was specified, ensure that the captured content is within
// this view. Get the frame for the captured content from the right
// presshell first.
nsIFrame* frame = nsnull;
nsIDocument* doc = gCaptureInfo.mContent->GetCurrentDoc();
if (doc) {
nsIPresShell *shell = doc->GetPrimaryShell();
if (shell) {
// not much can happen if frames are being destroyed so just return.
if (shell->FrameManager()->IsDestroyingFrames())
return;
frame = gCaptureInfo.mContent->GetPrimaryFrame();
}
}
// this view.
nsIFrame* frame = gCaptureInfo.mContent->GetPrimaryFrame();
if (frame) {
nsIView* view = frame->GetClosestView();
// if there is no view, capturing won't be handled any more, so
@ -5031,6 +5023,12 @@ PresShell::ContentRemoved(nsIDocument *aDocument,
nsresult
PresShell::ReconstructFrames(void)
{
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
// Have to make sure that the content notifications are flushed before we
// start messing with the frame model; otherwise we can get content doubling.
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
nsAutoCauseReflowNotifier crNotifier(this);
mFrameConstructor->BeginUpdate();
nsresult rv = mFrameConstructor->ReconstructDocElementHierarchy();
@ -7556,23 +7554,29 @@ PresShell::Observe(nsISupports* aSubject,
NS_ASSERTION(mViewManager, "View manager must exist");
nsIViewManager::UpdateViewBatch batch(mViewManager);
WalkFramesThroughPlaceholders(mPresContext, rootFrame,
&ReResolveMenusAndTrees, nsnull);
nsWeakFrame weakRoot(rootFrame);
// Have to make sure that the content notifications are flushed before we
// start messing with the frame model; otherwise we can get content doubling.
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
// Because "chrome:" URL equality is messy, reframe image box
// frames (hack!).
nsStyleChangeList changeList;
WalkFramesThroughPlaceholders(mPresContext, rootFrame,
ReframeImageBoxes, &changeList);
// Mark ourselves as not safe to flush while we're doing frame
// construction.
{
nsAutoScriptBlocker scriptBlocker;
++mChangeNestCount;
mFrameConstructor->ProcessRestyledFrames(changeList);
--mChangeNestCount;
if (weakRoot.IsAlive()) {
WalkFramesThroughPlaceholders(mPresContext, rootFrame,
&ReResolveMenusAndTrees, nsnull);
// Because "chrome:" URL equality is messy, reframe image box
// frames (hack!).
nsStyleChangeList changeList;
WalkFramesThroughPlaceholders(mPresContext, rootFrame,
ReframeImageBoxes, &changeList);
// Mark ourselves as not safe to flush while we're doing frame
// construction.
{
nsAutoScriptBlocker scriptBlocker;
++mChangeNestCount;
mFrameConstructor->ProcessRestyledFrames(changeList);
--mChangeNestCount;
}
}
batch.EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
#ifdef ACCESSIBILITY
InvalidateAccessibleSubtree(nsnull);

View File

@ -94,13 +94,7 @@ nsRefreshDriver::RemoveRefreshObserver(nsARefreshObserver *aObserver,
mozFlushType aFlushType)
{
ObserverArray& array = ArrayFor(aFlushType);
PRBool success = array.RemoveElement(aObserver);
if (ObserverCount() == 0) {
StopTimer();
}
return success;
return array.RemoveElement(aObserver);
}
void
@ -189,8 +183,14 @@ nsRefreshDriver::Notify(nsITimer *aTimer)
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
if (!presShell) {
// Things are being destroyed.
if (!presShell || ObserverCount() == 0) {
// Things are being destroyed, or we no longer have any observers.
// We don't want to stop the timer when observers are initially
// removed, because sometimes observers can be added and removed
// often depending on what other things are going on and in that
// situation we don't want to thrash our timer. So instead we
// wait until we get a Notify() call when we have no observers
// before stopping the timer.
StopTimer();
return NS_OK;
}
@ -225,9 +225,5 @@ nsRefreshDriver::Notify(nsITimer *aTimer)
}
}
if (ObserverCount() == 0) {
StopTimer();
}
return NS_OK;
}

View File

@ -46,6 +46,8 @@ include $(topsrcdir)/config/rules.mk
_CHROME_FILES = \
test_bug396024.xul \
bug396024_helper.xul \
test_bug396367-1.html \
test_bug396367-2.html \
test_bug482976.xul \
bug482976_helper.xul \
test_bug504311.xul \

View File

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=396367
-->
<head>
<title>Test for Bug 396367</title>
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script>
SimpleTest.waitForExplicitFinish();
function finish() {
ok(true, "didn't crash");
var docviewer = getdocviewer();
docviewer.textZoom = 1;
SimpleTest.finish();
}
function getdocviewer() {
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var navigator1 = top.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebNavigation);
var docShell = navigator1.QueryInterface(Components.interfaces.nsIDocShell);
var docviewer = docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
return docviewer;
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396367">Mozilla Bug 396367</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<input>
<script>document.body.setAttribute('style', 'display: -moz-box; overflow: scroll;');</script>
<script>
var docviewer = getdocviewer();
docviewer.textZoom=Math.floor(10*Math.random())/4+0.2;
document.documentElement.offsetHeight;
setTimeout(finish,10);
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,58 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=396367
-->
<head>
<title>Test for Bug 396367</title>
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<style>select::after { content:"m"; }</style>
<script>
SimpleTest.waitForExplicitFinish();
function finish() {
ok(true, "didn't crash");
var docviewer = getdocviewer();
docviewer.textZoom = 1;
SimpleTest.finish();
}
function getdocviewer() {
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var navigator1 = top.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebNavigation);
var docShell = navigator1.QueryInterface(Components.interfaces.nsIDocShell);
var docviewer = docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
return docviewer;
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396367">Mozilla Bug 396367</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<div style="overflow: scroll; float: left;">
<select></select>
<li style="display: table-cell;">
<script>
var docviewer = getdocviewer();
docviewer.textZoom=Math.floor(10*Math.random())/4+0.2;
document.documentElement.offsetHeight;
setTimeout(finish,10);
</script>
</li>
</div>
</pre>
</body>
</html>

View File

@ -23,13 +23,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=416896
<script class="testbody" type="text/javascript">
/** Test for Bug 416896 **/
// Ensure all of our sheets have unique inners and trigger a rule cascade
// reconstruct for each of them, so that all the rules the inspector APIs see
// will have the right parents. This is basicaly working around bug 253354.
for (var sheetIdx = 0; sheetIdx < document.styleSheets.length; ++sheetIdx) {
document.styleSheets[sheetIdx].insertRule("dummy {}", 0);
}
var inlineSheet = $("i").sheet;
isnot(inlineSheet, null, "Should have sheet here");

View File

@ -38,6 +38,9 @@ SimpleTest.waitForExplicitFinish();
function flash(doc, name) {
var d = doc.getElementById(name);
d.style.backgroundColor = d.style.backgroundColor == "blue" ? "yellow" : "blue";
// Now flush out style changes in that document, since our event listeners
// seem to assume that things will work that way.
d.getBoundingClientRect();
}
function le(v1, v2, s) {

View File

@ -300,20 +300,6 @@ NS_QUERYFRAME_HEAD(nsComboboxControlFrame)
NS_QUERYFRAME_ENTRY(nsIScrollableViewProvider)
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
NS_IMPL_QUERY_INTERFACE1(nsComboboxControlFrame, nsIRollupListener)
NS_IMETHODIMP_(nsrefcnt)
nsComboboxControlFrame::AddRef()
{
return 2;
}
NS_IMETHODIMP_(nsrefcnt)
nsComboboxControlFrame::Release()
{
return 1;
}
#ifdef ACCESSIBILITY
NS_IMETHODIMP nsComboboxControlFrame::GetAccessible(nsIAccessible** aAccessible)
{
@ -427,7 +413,7 @@ nsComboboxControlFrame::ShowList(PRBool aShowList)
if (view) {
nsIWidget* widget = view->GetWidget();
if (widget)
widget->CaptureRollupEvents(this, mDroppedDown, mDroppedDown);
widget->CaptureRollupEvents(this, nsnull, mDroppedDown, mDroppedDown);
}
}
@ -1226,7 +1212,7 @@ nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
if (view) {
nsIWidget* widget = view->GetWidget();
if (widget)
widget->CaptureRollupEvents(this, PR_FALSE, PR_TRUE);
widget->CaptureRollupEvents(this, nsnull, PR_FALSE, PR_TRUE);
}
}
}

View File

@ -98,7 +98,6 @@ public:
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
NS_DECL_ISUPPORTS_INHERITED
// nsIAnonymousContentCreator
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);

View File

@ -3520,6 +3520,9 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState,
(NS_BLOCK_HAS_FIRST_LETTER_STYLE & mState)) {
aLineLayout.SetFirstLetterStyleOK(PR_TRUE);
}
NS_ASSERTION(!((NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) &&
GetPrevContinuation()),
"first letter child bit should only be on first continuation");
// Reflow the frames that are already on the line first
nsresult rv = NS_OK;
@ -6318,8 +6321,12 @@ nsBlockFrame::Init(nsIContent* aContent,
// Copy over the block frame type flags
nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow;
// Don't copy NS_BLOCK_HAS_FIRST_LETTER_CHILD as that is set on the first
// continuation only.
SetFlags(blockFrame->mState &
(NS_BLOCK_FLAGS_MASK & ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET));
(NS_BLOCK_FLAGS_MASK &
(~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET &
~NS_BLOCK_HAS_FIRST_LETTER_CHILD)));
}
nsresult rv = nsBlockFrameSuper::Init(aContent, aParent, aPrevInFlow);

View File

@ -68,7 +68,7 @@ class nsTableColFrame;
* NS_BLOCK_HAS_FIRST_LETTER_CHILD means that there is an inflow first-letter
* frame among the block's descendants. If there is a floating first-letter
* frame, or the block has first-letter style but has no first letter, this
* bit is not set.
* bit is not set. This bit is set on the first continuation only.
*/
#define NS_BLOCK_NO_AUTO_MARGINS 0x00200000
#define NS_BLOCK_MARGIN_ROOT 0x00400000

View File

@ -303,6 +303,19 @@ nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
}
}
static void
ReParentChildListStyle(nsPresContext* aPresContext,
const nsFrameList::Slice& aFrames,
nsIFrame* aParentFrame)
{
nsFrameManager *frameManager = aPresContext->FrameManager();
for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) {
NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage");
frameManager->ReParentStyleContext(e.get());
}
}
NS_IMETHODIMP
nsInlineFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
@ -353,7 +366,16 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext,
}
// Insert the new frames at the beginning of the child list
// and set their parent pointer
mFrames.InsertFrames(this, nsnull, *prevOverflowFrames);
const nsFrameList::Slice& newFrames =
mFrames.InsertFrames(this, nsnull, *prevOverflowFrames);
// If our prev in flow was under the first continuation of a first-line
// frame then we need to reparent the style contexts to remove the
// the special first-line styling. In the lazilySetParentPointer case
// we reparent the style contexts when we set their parents in
// nsInlineFrame::ReflowFrames and nsInlineFrame::ReflowInlineFrame.
if (aReflowState.mLineLayout->GetInFirstLine()) {
ReParentChildListStyle(aPresContext, newFrames, this);
}
}
}
}
@ -455,6 +477,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
aStatus = NS_FRAME_COMPLETE;
nsLineLayout* lineLayout = aReflowState.mLineLayout;
PRBool inFirstLine = aReflowState.mLineLayout->GetInFirstLine();
nsFrameManager* frameManager = aPresContext->FrameManager();
PRBool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection);
nscoord leftEdge = 0;
// Don't offset by our start borderpadding if we have a prev continuation or
@ -497,6 +521,9 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
ReparentFloatsForInlineChild(irs.mLineContainer, frame, PR_FALSE);
}
frame->SetParent(this);
if (inFirstLine) {
frameManager->ReParentStyleContext(frame);
}
// We also need to check if frame has a next-in-flow. If it does, then set
// its parent frame pointer, too. Otherwise, if we reflow frame and it's
// complete we'll fail when deleting its next-in-flow which is no longer
@ -512,6 +539,9 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
ReparentFloatsForInlineChild(irs.mLineContainer, nextInFlow, PR_FALSE);
}
nextInFlow->SetParent(this);
if (inFirstLine) {
frameManager->ReParentStyleContext(nextInFlow);
}
}
// Fix the parent pointer for ::first-letter child frame next-in-flows,
@ -528,6 +558,9 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
"unexpected frame type");
if (mFrames.ContainsFrame(nextInFlow)) {
nextInFlow->SetParent(this);
if (inFirstLine) {
frameManager->ReParentStyleContext(nextInFlow);
}
}
else {
#ifdef DEBUG
@ -710,6 +743,9 @@ nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
}
for (nsIFrame* f = aFrame->GetNextSibling(); f; f = f->GetNextSibling()) {
f->SetParent(this);
if (lineLayout->GetInFirstLine()) {
aPresContext->FrameManager()->ReParentStyleContext(f);
}
}
}
}
@ -927,19 +963,6 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
// nsLineFrame implementation
static void
ReParentChildListStyle(nsPresContext* aPresContext,
const nsFrameList::Slice& aFrames,
nsIFrame* aParentFrame)
{
nsFrameManager *frameManager = aPresContext->FrameManager();
for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) {
NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage");
frameManager->ReParentStyleContext(e.get());
}
}
nsIFrame*
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{

View File

@ -467,7 +467,8 @@ public:
{
if (mSelection && mPresContext)
{
nsWeakFrame frame = mPresContext->GetPrimaryFrameFor(mContent);
nsWeakFrame frame =
mContent ? mPresContext->GetPrimaryFrameFor(mContent) : nsnull;
mContent = nsnull;
mFrameSelection->HandleDrag(frame, mPoint);

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Dynamic bidi bug</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
p { width: 3ch;}
</style>
</head>
<body>
<p dir="rtl">0 123 4</p>
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Dynamic bidi bug</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
p { width: 3ch;}
</style>
<script type="text/javascript">
function flip()
{
var flipped= document.getElementById('flipped');
flipped.dir = "rtl";
}
</script>
</head>
<body onload="flip()">
<p id="flipped">0 123 4</p>
</body>
</html>

View File

@ -44,3 +44,4 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 386339.html 386339-ref.html
== 503269-1.html 503269-1-ref.html
== 503957-1.html 503957-1-ref.html
== 525740-1.html 525740-1-ref.html
== 536963-1.html 536963-1-ref.html

View File

@ -0,0 +1,11 @@
<html>
<head>
<style>
div::first-letter { color: red; font-size: 200%; background-color: blue; }
</style>
</head>
<body>
<div>
T
</div>
</body>

View File

@ -0,0 +1,20 @@
<html class="reftest-wait">
<head>
<style>
div::first-letter { color: red; font-size: 200%; background-color: blue; }
</style>
<script>
function boom() {
document.documentElement.offsetWidth;
var s = document.getElementById("s");
s.parentNode.removeChild(s);
document.documentElement.offsetWidth;
document.documentElement.removeAttribute("class");
}
</script>
</head>
<body onload="boom();">
<div>
<span id="s" style="position: absolute;">abcdefh</span>T
</div>
</body>

View File

@ -53,3 +53,4 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 329069-1.html 329069-1-ref.html # failu
== 429968-2c.html 429968-2-ref.html
== 441418-1.html 441418-1-ref.html
== 469227-1.html 469227-1-ref.html
== 484400-1.html 484400-1-ref.html

View File

@ -0,0 +1,18 @@
<html>
<head>
<style>
div::first-line { color: red; background-color: blue; font-size: 200%; text-transform: uppercase; }
</style>
</head>
<body>
<div>
Line number one.<br/>Line number two.<br/>Line number three.
</div>
<div style="height: 50000px;">
<!-- to force a scrollbar -->
</div>
</body>
</html>

View File

@ -0,0 +1,18 @@
<html>
<head>
<style>
div::first-line { color: red; background-color: blue; font-size: 200%; text-transform: uppercase; }
</style>
</head>
<body>
<div>
<span>Line number one.<br/>Line number two.<br/>Line number three.</span>
</div>
<div style="height: 50000px;">
<!-- to force a scrollbar -->
</div>
</body>
</html>

View File

@ -0,0 +1,14 @@
<html>
<head>
<style>
div::first-line { color: red; background-color: blue; font-size: 200%; text-transform: uppercase; }
</style>
</head>
<body>
<div>
Line number one.<br/>Line number two.<br/>Line number three.
</div>
</body>
</html>

View File

@ -0,0 +1,14 @@
<html>
<head>
<style>
div::first-line { color: red; background-color: blue; font-size: 200%; text-transform: uppercase; }
</style>
</head>
<body>
<div>
<span>Line number one.<br/>Line number two.<br/>Line number three.</span>
</div>
</body>
</html>

View File

@ -26,6 +26,8 @@ fails == out-of-flow-1d.html out-of-flow-1-ref.html # bug 396645
== stress-11.xhtml stress-11-ref.xhtml
== border-not-apply.html border-not-apply-ref.html
== 287088-1.html 287088-1-ref.html
== 287088-2.html 287088-2-ref.html
== 403177-1.html 403177-1-ref.html
== 469227-2.html 469227-2-ref.html
== 469227-3.html 469227-3-ref.html

View File

@ -499,11 +499,16 @@ tr:focus, tt:focus, u:focus, ul:focus, var:focus {
}
/* hidden elements */
area, base, basefont, head, meta, script, style, title,
base, basefont, head, meta, script, style, title,
noembed, param {
display: none;
}
area {
/* Don't give it frames other than its imageframe */
display: none ! important;
}
/* media elements */
video > xul|videocontrols, audio > xul|videocontrols {
display: -moz-box;

View File

@ -310,9 +310,13 @@ public:
friend class nsXULMenuCommandEvent;
NS_DECL_ISUPPORTS
NS_DECL_NSIROLLUPLISTENER
NS_DECL_NSITIMERCALLBACK
// nsIRollupListener
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent);
NS_IMETHOD ShouldRollupOnMouseWheelEvent(PRBool *aShould);
NS_IMETHOD ShouldRollupOnMouseActivate(PRBool *aShould);
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain);
virtual void AdjustPopupsOnWindowChange(void);

View File

@ -127,11 +127,10 @@ void nsMenuChainItem::Detach(nsMenuChainItem** aRoot)
}
}
NS_IMPL_ISUPPORTS5(nsXULPopupManager,
NS_IMPL_ISUPPORTS4(nsXULPopupManager,
nsIDOMKeyListener,
nsIDOMEventListener,
nsIMenuRollup,
nsIRollupListener,
nsITimerCallback)
nsXULPopupManager::nsXULPopupManager() :
@ -1391,7 +1390,7 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup)
return;
if (mWidget) {
mWidget->CaptureRollupEvents(this, PR_FALSE, PR_FALSE);
mWidget->CaptureRollupEvents(this, this, PR_FALSE, PR_FALSE);
mWidget = nsnull;
}
@ -1400,7 +1399,8 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup)
nsCOMPtr<nsIWidget> widget;
popup->GetWidget(getter_AddRefs(widget));
if (widget) {
widget->CaptureRollupEvents(this, PR_TRUE, popup->ConsumeOutsideClicks());
widget->CaptureRollupEvents(this, this, PR_TRUE,
popup->ConsumeOutsideClicks());
mWidget = widget;
popup->AttachedDismissalListener();
}

View File

@ -89,6 +89,8 @@ nsJARInputStream::InitFile(nsJAR *aJar, nsZipItem *item)
// Must keep handle to filepointer and mmap structure as long as we need access to the mmapped data
mFd = aJar->mZip.GetFD();
mZs.next_in = aJar->mZip.GetData(item);
if (!mZs.next_in)
return NS_ERROR_FILE_CORRUPTED;
mZs.avail_in = item->Size();
mOutSize = item->RealSize();
mZs.total_out = 0;

Binary file not shown.

View File

@ -0,0 +1,69 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Taras Glek <tglek@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function wrapInputStream(input)
{
var nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
var factory = Components.classes["@mozilla.org/scriptableinputstream;1"];
var wrapper = factory.createInstance(nsIScriptableInputStream);
wrapper.init(input);
return wrapper;
}
// Check that files can be read from after closing zipreader
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// the build script have created the zip we can test on in the current dir.
var file = do_get_file("data/test_corrupt.zip");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipreader.open(file);
// var entries = zipreader.findEntries(null);
// the signature for file is corrupt, should not segfault
var failed = false;
try {
var stream = wrapInputStream(zipreader.getInputStream("file"));
stream.read(1024);
} catch (ex) {
failed = true;
}
do_check_true(failed);
}

View File

@ -16,9 +16,12 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Taras Glek <tglek@mozilla.com>
* Portions created by the Initial Developer are Copyright (C) 2006
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Taras Glek <tglek@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or

View File

@ -16,9 +16,12 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Taras Glek <tglek@mozilla.com>
* Portions created by the Initial Developer are Copyright (C) 2006
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Taras Glek <tglek@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or

View File

@ -473,7 +473,7 @@ void
ClearSubclass(HWND hWnd)
{
if (GetProp(hWnd, "MozillaWndProc")) {
::SetWindowLong(hWnd, GWL_WNDPROC, (long)GetProp(hWnd, "MozillaWndProc"));
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)GetProp(hWnd, "MozillaWndProc"));
RemoveProp(hWnd, "MozillaWndProc");
RemoveProp(hWnd, "InstanceData");
}
@ -484,7 +484,7 @@ SetSubclass(HWND hWnd, InstanceData* instanceData)
{
// Subclass the plugin window so we can handle our own windows events.
SetProp(hWnd, "InstanceData", (HANDLE)instanceData);
WNDPROC origProc = (WNDPROC)::SetWindowLong(hWnd, GWL_WNDPROC, (long)PluginWndProc);
WNDPROC origProc = (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)PluginWndProc);
SetProp(hWnd, "MozillaWndProc", (HANDLE)origProc);
}

View File

@ -12,8 +12,9 @@
<iframe id="f1" width="100" height="100" onload="frameLoaded()"
src="data:text/html,%3Cbody%20style='height:%208000px'%3E%3Cp%3EHello%3C/p%3EGoodbye%3C/body%3E"/>
<!-- <body style='height: 8000px'><p>Hello</p><span id='s'>Goodbye<span></body> -->
<iframe id="f2" type="content" showcaret="true" width="100" height="100" onload="frameLoaded()"
src="data:text/html,%3Cbody%20style='height:%208000px'%3E%3Cp%3EHello%3C/p%3EGoodbye%3C/body%3E"/>
src="data:text/html,%3Cbody%20style%3D%27height%3A%208000px%27%3E%3Cp%3EHello%3C%2Fp%3E%3Cspan%20id%3D%27s%27%3EGoodbye%3Cspan%3E%3C%2Fbody%3E"/>
<script>
<![CDATA[
@ -21,7 +22,7 @@
var framesLoaded = 0;
var otherWindow = null;
function frameLoaded() { if (++framesLoaded == 2) runTest(); }
function frameLoaded() { if (++framesLoaded == 2) SimpleTest.waitForFocus(runTest); }
SimpleTest.waitForExplicitFinish();
function runTest()
@ -42,7 +43,9 @@ function runTest()
window.frames[1].focus();
document.commandDispatcher.getControllerForCommand("cmd_scrollBottom").doCommand("cmd_scrollBottom");
is(frames[1].scrollY, 0, "scrollY for showcaret");
ok(frames[1].scrollY <
frames[1].document.getElementById('s').getBoundingClientRect().top,
"scrollY for showcaret");
isnot(sel2.focusNode, frames[1].document.body, "focusNode for showcaret");
ok(sel2.anchorOffset > 0, "focusOffset for showcaret");

View File

@ -8,8 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436084
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -65,7 +64,7 @@ var prefs = [
["keyCode.modifier", "char", "none"],
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -83,5 +82,7 @@ function onLoad()
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -8,8 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436084
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -47,7 +46,7 @@ var prefs = [
["keyCode.modifier", "char", "none"],
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -65,5 +64,7 @@ function onLoad()
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -4,8 +4,7 @@
<window title="Mozilla Bug 444801"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -41,7 +40,7 @@
["keyCode.modifier", "char", "none"],
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -59,6 +58,8 @@
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]>
</script>
</window>

View File

@ -4,8 +4,7 @@
<window title="Mozilla Bug 444801"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -53,7 +52,7 @@
["keyCode.up", "int", 85], // DOM_VK_U
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -71,6 +70,8 @@
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]>
</script>
</window>

View File

@ -8,8 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436084
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -58,7 +57,7 @@ var prefs = [
["keyCode.modifier", "char", "none"],
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -76,5 +75,7 @@ function onLoad()
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -8,8 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436084
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -114,7 +113,7 @@ var prefs = [
["keyCode.modifier", "char", "none"],
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -132,5 +131,7 @@ function onLoad()
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -8,8 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436084
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
@ -97,7 +96,7 @@ var prefs = [
["keyCode.modifier", "char", "none"],
];
function onLoad()
function runtest()
{
prepareTest(prefs);
@ -115,5 +114,7 @@ function onLoad()
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -58,6 +58,7 @@ EXPORTS = \
nsINativeKeyBindings.h \
nsIDeviceContextSpec.h \
nsIMenuRollup.h \
nsIRollupListener.h \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
@ -97,7 +98,6 @@ XPIDLSRCS = \
nsIClipboard.idl \
nsIClipboardHelper.idl \
nsIClipboardOwner.idl \
nsIRollupListener.idl \
nsIBaseWindow.idl \
nsIBidiKeyboard.idl \
nsIScreen.idl \

View File

@ -39,34 +39,33 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#ifndef __nsIRollupListener_h__
#define __nsIRollupListener_h__
interface nsIContent;
class nsIContent;
class nsIRollupListener {
public:
[uuid(0CA103E5-80D4-4B81-A310-BE0708F8EAA9)]
interface nsIRollupListener : nsISupports
{
/**
* Notifies the object to rollup, optionally returning the node that
* was just rolled up.
*
* aCount is the number of popups in a chain to close. If this is
* PR_UINT32_MAX, then all popups are closed.
*
* @result NS_Ok if no errors
*/
nsIContent Rollup(in unsigned long aCount);
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent) = 0;
/**
* Asks the RollupListener if it should rollup on mousevents
* @result NS_Ok if no errors
*/
void ShouldRollupOnMouseWheelEvent(out PRBool aShould);
NS_IMETHOD ShouldRollupOnMouseWheelEvent(PRBool *aShould) = 0;
/**
* Asks the RollupListener if it should rollup on mouse activate, eg. X-Mouse
* @result NS_Ok if no errors
*/
void ShouldRollupOnMouseActivate(out PRBool aShould);
NS_IMETHOD ShouldRollupOnMouseActivate(PRBool *aShould) = 0;
};
#endif /* __nsIRollupListener_h__ */

View File

@ -60,6 +60,7 @@ class nsIRenderingContext;
class nsIDeviceContext;
struct nsFont;
class nsIRollupListener;
class nsIMenuRollup;
class nsGUIEvent;
class imgIContainer;
class gfxASurface;
@ -767,7 +768,8 @@ class nsIWidget : public nsISupports {
* @param aConsumeRollupEvent PR_TRUE consumes the rollup event, PR_FALSE dispatches rollup event
*
*/
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) = 0;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent) = 0;
/**
* Bring this window to the user's attention. This is intended to be a more

View File

@ -92,6 +92,7 @@ static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
// Rollup Listener - static variable defintions
static nsIRollupListener * gRollupListener = nsnull;
static nsIMenuRollup * gMenuRollup = nsnull;
static nsIWidget * gRollupWidget = nsnull;
static PRBool gRollupConsumeRollupEvent = PR_FALSE;
// Tracking last activated BWindow
@ -712,7 +713,10 @@ NS_METHOD nsWindow::CaptureMouse(PRBool aCapture)
//-------------------------------------------------------------------------
// Capture Roolup Events
//-------------------------------------------------------------------------
NS_METHOD nsWindow::CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent)
NS_METHOD nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
if (!mEnabled)
return NS_OK;
@ -724,16 +728,18 @@ NS_METHOD nsWindow::CaptureRollupEvents(nsIRollupListener * aListener, PRBool aD
// assure that remains true.
NS_ASSERTION(!gRollupWidget, "rollup widget reassigned before release");
gRollupConsumeRollupEvent = aConsumeRollupEvent;
NS_IF_RELEASE(gRollupListener);
NS_IF_RELEASE(gRollupWidget);
gRollupListener = aListener;
NS_ADDREF(aListener);
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWidget = this;
NS_ADDREF(this);
}
else
{
NS_IF_RELEASE(gRollupListener);
gRollupListener == nsnull;
NS_IF_RELEASE(gMenuRollup);
NS_IF_RELEASE(gRollupWidget);
}
@ -783,11 +789,10 @@ nsWindow::DealWithPopups(uint32 methodID, nsPoint pos)
// want to rollup if the click is in a parent menu of the current submenu.
if (rollup)
{
nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(gRollupListener) );
if ( menuRollup )
if ( gMenuRollup )
{
nsAutoTArray<nsIWidget*, 5> widgetChain;
menuRollup->GetSubmenuWidgetChain(&widgetChain);
gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
for ( PRUint32 i = 0; i < widgetChain.Length(); ++i )
{

View File

@ -109,6 +109,7 @@ public:
NS_IMETHOD Show(PRBool bState);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);
NS_IMETHOD IsVisible(PRBool & aState);

View File

@ -360,7 +360,8 @@ public:
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD SetTitle(const nsAString& title);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);

View File

@ -153,6 +153,7 @@ static void blinkRgn(RgnHandle rgn);
#endif
nsIRollupListener * gRollupListener = nsnull;
nsIMenuRollup * gMenuRollup = nsnull;
nsIWidget * gRollupWidget = nsnull;
PRUint32 gLastModifierState = 0;
@ -1891,6 +1892,7 @@ nsIntPoint nsChildView::WidgetToScreenOffset()
}
NS_IMETHODIMP nsChildView::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
@ -2749,12 +2751,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
// we don't want to rollup if the click is in a parent menu of
// the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX;
nsCOMPtr<nsIMenuRollup> menuRollup;
menuRollup = (do_QueryInterface(gRollupListener));
if (menuRollup) {
if (gMenuRollup) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
menuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = menuRollup->GetSubmenuWidgetChain(&widgetChain);
gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i = 0; i < widgetChain.Length(); i++) {
nsIWidget* widget = widgetChain[i];
NSWindow* currWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW);

View File

@ -245,7 +245,8 @@ public:
const nsTArray<nsIntRect>& aDestRects,
const nsTArray<Configuration>& aConfigurations);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
virtual PRBool HasPendingInputEvent();
virtual nsTransparencyMode GetTransparencyMode();

View File

@ -66,6 +66,7 @@
#include "nsStyleConsts.h"
#include "nsNativeThemeColors.h"
#include "nsChildView.h"
#include "nsIMenuRollup.h"
#include "gfxPlatform.h"
#include "qcms.h"
@ -89,6 +90,7 @@ extern NSMenu* sApplicationMenu; // Application menu shared by all menubars
// defined in nsChildView.mm
extern nsIRollupListener * gRollupListener;
extern nsIMenuRollup * gMenuRollup;
extern nsIWidget * gRollupWidget;
extern BOOL gSomeMenuBarPainted;
@ -1344,17 +1346,21 @@ nsMenuBarX* nsCocoaWindow::GetMenuBar()
}
NS_IMETHODIMP nsCocoaWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
NS_IF_RELEASE(gRollupListener);
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
NS_IF_RELEASE(gRollupWidget);
if (aDoCapture) {
gRollupListener = aListener;
NS_ADDREF(aListener);
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWidget = this;
NS_ADDREF(this);

View File

@ -430,7 +430,7 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
Init();
if (!elib)
return NS_ERROR_FAILURE;
return NS_ERROR_NOT_AVAILABLE;
nsCOMPtr<nsIStreamLoader> loader;
rv = NS_NewStreamLoader(getter_AddRefs(loader), aURL, this);

View File

@ -290,7 +290,8 @@ static PRBool gGlobalsInitialized = PR_FALSE;
static PRBool gRaiseWindows = PR_TRUE;
static nsWindow *gPluginFocusWindow = NULL;
static nsCOMPtr<nsIRollupListener> gRollupListener;
static nsIRollupListener* gRollupListener;
static nsIMenuRollup* gMenuRollup;
static nsWeakPtr gRollupWindow;
static PRBool gConsumeRollupEvent;
@ -762,6 +763,7 @@ nsWindow::Destroy(void)
if (static_cast<nsIWidget *>(this) == rollupWidget.get()) {
if (gRollupListener)
gRollupListener->Rollup(nsnull, nsnull);
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull;
gRollupListener = nsnull;
}
@ -2150,6 +2152,7 @@ nsWindow::CaptureMouse(PRBool aCapture)
NS_IMETHODIMP
nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
@ -2165,6 +2168,9 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
if (aDoCapture) {
gConsumeRollupEvent = aConsumeRollupEvent;
gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*>
(this));
// real grab is only done when there is no dragging
@ -2180,6 +2186,7 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
gtk_grab_remove(widget);
}
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull;
}
@ -5340,11 +5347,9 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY,
// we don't want to rollup if the clickis in a parent menu of
// the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX;
nsCOMPtr<nsIMenuRollup> menuRollup;
menuRollup = (do_QueryInterface(gRollupListener));
if (menuRollup) {
if (gMenuRollup) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = menuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i=0; i<widgetChain.Length(); ++i) {
nsIWidget* widget = widgetChain[i];
GdkWindow* currWindow =
@ -5377,6 +5382,7 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY,
} else {
gRollupWindow = nsnull;
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
}
return retVal;

View File

@ -189,6 +189,7 @@ public:
NS_IMETHOD EnableDragDrop(PRBool aEnable);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);

View File

@ -120,6 +120,7 @@ BOOL nsWindow::sIsRegistered = FALSE;
// Rollup Listener - global variable defintions
////////////////////////////////////////////////////
nsIRollupListener * gRollupListener = nsnull;
nsIMenuRollup * gMenuRollup = nsnull;
nsIWidget * gRollupWidget = nsnull;
PRBool gRollupConsumeRollupEvent = PR_FALSE;
////////////////////////////////////////////////////
@ -453,6 +454,7 @@ PRBool nsWindow::DispatchDragDropEvent(PRUint32 aMsg)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
@ -462,15 +464,16 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
assure that remains true. */
NS_ASSERTION(!gRollupWidget, "rollup widget reassigned before release");
gRollupConsumeRollupEvent = aConsumeRollupEvent;
NS_IF_RELEASE(gRollupListener);
NS_IF_RELEASE(gRollupWidget);
gRollupListener = aListener;
NS_ADDREF(aListener);
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWidget = this;
NS_ADDREF(this);
} else {
NS_IF_RELEASE(gRollupListener);
//gRollupListener = nsnull;
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
NS_IF_RELEASE(gRollupWidget);
}
@ -539,10 +542,9 @@ nsWindow :: DealWithPopups ( ULONG inMsg, MRESULT* outResult )
// want to rollup if the click is in a parent menu of the current submenu.
PRUint32 popupsToRollup = PR_UINT32_MAX;
if (rollup) {
nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(gRollupListener) );
if ( menuRollup ) {
if ( gMenuRollup ) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = menuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) {
nsIWidget* widget = widgetChain[i];
if ( nsWindow::EventIsInsideWindow((nsWindow*)widget) ) {
@ -639,10 +641,9 @@ MRESULT EXPENTRY fnwpNSWindow( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
// If we're dealing with menus, we probably have submenus and we don't
// want to rollup if the click is in a parent menu of the current submenu.
if (rollup) {
nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(gRollupListener) );
if ( menuRollup ) {
if ( gMenuRollup ) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
menuRollup->GetSubmenuWidgetChain ( &widgetChain );
gMenuRollup->GetSubmenuWidgetChain ( &widgetChain );
for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) {
nsIWidget* widget = widgetChain[i];
if ( nsWindow::EventIsInsideWindow((nsWindow*)widget) ) {
@ -972,7 +973,7 @@ NS_METHOD nsWindow::Destroy()
if (gRollupListener) {
gRollupListener->Rollup(PR_UINT32_MAX, nsnull);
}
CaptureRollupEvents(nsnull, PR_FALSE, PR_TRUE);
CaptureRollupEvents(nsnull, nsnull, PR_FALSE, PR_TRUE);
}
if (mWnd) {

View File

@ -148,7 +148,8 @@ class nsWindow : public nsBaseWidget
virtual nsIntPoint WidgetToScreenOffset();
NS_IMETHOD DispatchEvent( struct nsGUIEvent *event, nsEventStatus &aStatus);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent);
virtual PRBool HasPendingInputEvent();

View File

@ -92,7 +92,9 @@ public:
NS_IMETHOD SetModal(PRBool aModal);
NS_IMETHOD Show(PRBool state);
inline NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) { return NS_OK; }
inline NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, nsIMenuRollup *aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent)
{ return NS_OK; }
inline NS_IMETHOD IsVisible(PRBool &aState) { aState = mShown; return NS_OK; }

View File

@ -59,6 +59,7 @@
#include "nsClipboard.h"
#include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIServiceManager.h"
#include "nsIAppShell.h"
@ -74,6 +75,7 @@
static PhTile_t *GetWindowClipping( PtWidget_t *aWidget );
nsIRollupListener *nsWindow::gRollupListener = nsnull;
nsIMenuRollup *nsWindow::gMenuRollup = nsnull;
nsIWidget *nsWindow::gRollupWidget = nsnull;
static PtWidget_t *gMenuRegion;
@ -171,15 +173,21 @@ void nsWindow::DestroyNativeChildren(void)
}
}
NS_IMETHODIMP nsWindow::CaptureRollupEvents( nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent ) {
NS_IMETHODIMP nsWindow::CaptureRollupEvents( nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent )
{
PtWidget_t *grabWidget;
grabWidget = mWidget;
if (aDoCapture) {
NS_IF_RELEASE(gRollupListener);
gRollupListener = nsnull;
NS_IF_RELEASE(gRollupWidget);
gRollupListener = aListener;
NS_ADDREF(aListener);
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWidget = this;
NS_ADDREF(this);
@ -203,8 +211,8 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents( nsIRollupListener * aListener, PRBo
}
}
else {
NS_IF_RELEASE(gRollupListener);
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
NS_IF_RELEASE(gRollupWidget);
gRollupWidget = nsnull;

View File

@ -91,6 +91,7 @@ public:
}
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);
@ -155,6 +156,7 @@ private:
PRBool mIsTooSmall;
PRBool mIsDestroying;
static nsIRollupListener *gRollupListener;
static nsIMenuRollup* gMenuRollup;
static nsIWidget *gRollupWidget;
};

View File

@ -124,7 +124,7 @@ nsSound::Init()
EsdOpenSoundType EsdOpenSound;
elib = PR_LoadLibrary("libesd.so.0");
if (!elib) return NS_ERROR_FAILURE;
if (!elib) return NS_ERROR_NOT_AVAILABLE;
EsdOpenSound = (EsdOpenSoundType) PR_FindFunctionSymbol(elib, "esd_open_sound");
@ -368,7 +368,7 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
Init();
if (!elib)
return NS_ERROR_FAILURE;
return NS_ERROR_NOT_AVAILABLE;
nsCOMPtr<nsIStreamLoader> loader;
rv = NS_NewStreamLoader(getter_AddRefs(loader), aURL, this);

View File

@ -114,7 +114,8 @@ static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
static const int WHEEL_DELTA = 120;
static PRBool gGlobalsInitialized = PR_FALSE;
static nsCOMPtr<nsIRollupListener> gRollupListener;
static nsIRollupListener* gRollupListener;
static nsIMenuRollup* gMenuRollup;
static nsWeakPtr gRollupWindow;
static PRBool gConsumeRollupEvent;
@ -250,6 +251,7 @@ nsWindow::Destroy(void)
gRollupListener->Rollup(nsnull, nsnull);
gRollupWindow = nsnull;
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
}
Show(PR_FALSE);
@ -802,6 +804,7 @@ nsWindow::CaptureMouse(PRBool aCapture)
NS_IMETHODIMP
nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
@ -813,10 +816,14 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
if (aDoCapture) {
gConsumeRollupEvent = aConsumeRollupEvent;
gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*>(this));
}
else {
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull;
}
@ -844,11 +851,9 @@ check_for_rollup(double aMouseX, double aMouseY,
// we don't want to rollup if the clickis in a parent menu of
// the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX;
nsCOMPtr<nsIMenuRollup> menuRollup;
menuRollup = (do_QueryInterface(gRollupListener));
if (menuRollup) {
if (gMenuRollup) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = menuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i=0; i<widgetChain.Length(); ++i) {
nsIWidget* widget = widgetChain[i];
QWidget* currWindow =
@ -874,6 +879,7 @@ check_for_rollup(double aMouseX, double aMouseY,
} else {
gRollupWindow = nsnull;
gRollupListener = nsnull;
gMenuRollup = nsnull;
}
return retVal;

View File

@ -175,6 +175,7 @@ public:
NS_IMETHOD EnableDragDrop(PRBool aEnable);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);

View File

@ -256,6 +256,7 @@ UINT nsWindow::sHookTimerId = 0;
// Rollup Listener
nsIRollupListener* nsWindow::sRollupListener = nsnull;
nsIMenuRollup* nsWindow::sMenuRollup = nsnull;
nsIWidget* nsWindow::sRollupWidget = nsnull;
PRBool nsWindow::sRollupConsumeEvent = PR_FALSE;
@ -2652,6 +2653,7 @@ NS_METHOD nsWindow::CaptureMouse(PRBool aCapture)
**************************************************************/
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
@ -2661,10 +2663,11 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
assure that remains true. */
NS_ASSERTION(!sRollupWidget, "rollup widget reassigned before release");
sRollupConsumeEvent = aConsumeRollupEvent;
NS_IF_RELEASE(sRollupListener);
NS_IF_RELEASE(sRollupWidget);
NS_IF_RELEASE(sMenuRollup);
sRollupListener = aListener;
NS_ADDREF(aListener);
sMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
sRollupWidget = this;
NS_ADDREF(this);
@ -2676,7 +2679,8 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
#endif
} else {
NS_IF_RELEASE(sRollupListener);
sRollupListener = nsnull;
NS_IF_RELEASE(sMenuRollup);
NS_IF_RELEASE(sRollupWidget);
#ifndef WINCE
@ -5904,7 +5908,7 @@ void nsWindow::OnDestroy()
if ( this == sRollupWidget ) {
if ( sRollupListener )
sRollupListener->Rollup(nsnull, nsnull);
CaptureRollupEvents(nsnull, PR_FALSE, PR_TRUE);
CaptureRollupEvents(nsnull, nsnull, PR_FALSE, PR_TRUE);
}
// If IME is disabled, restore it.
@ -6792,10 +6796,9 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara
// want to rollup if the click is in a parent menu of the current submenu.
PRUint32 popupsToRollup = PR_UINT32_MAX;
if (rollup) {
nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(sRollupListener) );
if ( menuRollup ) {
if ( sMenuRollup ) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = menuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = sMenuRollup->GetSubmenuWidgetChain(&widgetChain);
for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) {
nsIWidget* widget = widgetChain[i];
if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)widget) ) {

View File

@ -153,7 +153,8 @@ public:
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
NS_IMETHOD EnableDragDrop(PRBool aEnable);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
virtual PRBool HasPendingInputEvent();
gfxASurface *GetThebesSurface();
@ -462,6 +463,7 @@ protected:
static nsIWidget* sRollupWidget;
static PRBool sRollupConsumeEvent;
static nsIRollupListener* sRollupListener;
static nsIMenuRollup* sMenuRollup;
// Mouse Clicks - static variable definitions for figuring
// out 1 - 3 Clicks.

View File

@ -564,6 +564,9 @@ nsFastLoadFileReader::Read(char* aBuffer, PRUint32 aCount, PRUint32 *aBytesRead)
entry->mBytesLeft -= 8;
}
}
if (!mFileData)
return NS_BASE_STREAM_CLOSED;
PRUint32 count = PR_MIN(mFileLen - mFilePos, aCount);
memcpy(aBuffer, mFileData+mFilePos, count);
*aBytesRead = count;
@ -590,6 +593,9 @@ nsFastLoadFileReader::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
NS_ASSERTION(!entry || (!entry->mNeedToSeek && entry->mBytesLeft != 0),
"ReadSegments called from above nsFastLoadFileReader layer?!");
if (!mFileData)
return NS_BASE_STREAM_CLOSED;
PRUint32 count = PR_MIN(mFileLen - mFilePos, aCount);
// Errors returned from the writer get ignored.
@ -860,25 +866,36 @@ nsFastLoadFileReader::Open()
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(mFile, &rv);
if (NS_FAILED(rv))
return rv;
rv = localFile->OpenNSPRFileDesc(PR_RDONLY, 0, &mFd);
PRFileDesc *fd; // OS file-descriptor
rv = localFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd);
if (NS_FAILED(rv))
return rv;
PRInt64 size = PR_Available64(mFd);
if (size >= PR_INT32_MAX)
PRInt64 size = PR_Available64(fd);
if (size >= PR_INT32_MAX) {
PR_Close(fd);
return NS_ERROR_FILE_TOO_BIG;
}
mFileLen = (PRUint32) size;
mFileMap = PR_CreateFileMap(mFd, mFileLen, PR_PROT_READONLY);
if (!mFileMap)
if (mFileLen < sizeof(nsFastLoadHeader)) {
PR_Close(fd);
return NS_ERROR_FAILURE;
}
mFileMap = PR_CreateFileMap(fd, mFileLen, PR_PROT_READONLY);
if (!mFileMap) {
PR_Close(fd);
return NS_ERROR_FAILURE;
}
mFileData = (PRUint8*) PR_MemMap(mFileMap, 0, mFileLen);
// At this point the non-mmap file descriptor is no longer needed
PR_Close(fd);
if (mFileLen < sizeof(nsFastLoadHeader))
if (!mFileData)
return NS_ERROR_FAILURE;
#if defined(XP_UNIX)
madvise((char *)mFileData, mFileLen, MADV_WILLNEED);
#endif
@ -922,16 +939,18 @@ nsFastLoadFileReader::Close()
// a session not so much for reading objects as for its footer information,
// which primes the updater's tables so that after the update completes, the
// FastLoad file has a superset footer.
if (mFd) {
if (mFileData)
PR_MemUnmap(mFileData, mFileLen);
if (mFileData) {
PR_MemUnmap(mFileData, mFileLen);
mFileData = nsnull;
if (mFileMap)
PR_CloseFileMap(mFileMap);
mFileMap = nsnull;
PR_Close(mFd);
mFd = nsnull;
}
if (mFileMap) {
PR_CloseFileMap(mFileMap);
mFileMap = nsnull;
}
mFileLen = 0;
mFilePos = 0;
if (!mFooter.mObjectMap)
return NS_OK;

View File

@ -263,7 +263,7 @@ class nsFastLoadFileReader
{
public:
nsFastLoadFileReader(nsIFile *aFile)
: mCurrentDocumentMapEntry(nsnull), mFile(aFile), mFd(nsnull),
: mCurrentDocumentMapEntry(nsnull), mFile(aFile),
mFileLen(0), mFilePos(0), mFileMap(nsnull), mFileData(nsnull)
{
MOZ_COUNT_CTOR(nsFastLoadFileReader);
@ -396,7 +396,6 @@ class nsFastLoadFileReader
friend class nsFastLoadFileUpdater;
nsIFile *mFile; // .mfasl file
PRFileDesc *mFd; // OS file-descriptor
PRUint32 mFileLen; // length of file
PRUint32 mFilePos; // current position within file
PRFileMap *mFileMap;// nspr datastructure for mmap