From 36a70da56f473b6b843a1e0bb130f44cba1d488c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sat, 5 Jan 2008 06:44:38 +0000 Subject: [PATCH] Make image controls splittable just like regular images. Bug 409659, r+sr=roc, a=dsicore git-svn-id: svn://10.0.0.236/trunk@242428 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 6 ++++++ mozilla/layout/forms/nsImageControlFrame.cpp | 12 +++++++++--- mozilla/layout/generic/nsImageFrame.cpp | 10 ++++------ mozilla/layout/reftests/bugs/409659-1-ref.html | 6 ++++++ mozilla/layout/reftests/bugs/409659-1a.html | 7 +++++++ mozilla/layout/reftests/bugs/409659-1b.html | 6 ++++++ mozilla/layout/reftests/bugs/409659-1c.html | 6 ++++++ mozilla/layout/reftests/bugs/409659-1d.html | 9 +++++++++ mozilla/layout/reftests/bugs/reftest.list | 4 ++++ 9 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 mozilla/layout/reftests/bugs/409659-1-ref.html create mode 100644 mozilla/layout/reftests/bugs/409659-1a.html create mode 100644 mozilla/layout/reftests/bugs/409659-1b.html create mode 100644 mozilla/layout/reftests/bugs/409659-1c.html create mode 100644 mozilla/layout/reftests/bugs/409659-1d.html diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 6d99bbea532..cb10b00000f 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -10698,6 +10698,12 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext, if (newFrame) { newFrame->Init(content, aParentFrame, aFrame); } + } else if (nsGkAtoms::imageControlFrame == frameType) { + newFrame = NS_NewImageControlFrame(shell, styleContext); + + if (newFrame) { + newFrame->Init(content, aParentFrame, aFrame); + } } else if (nsGkAtoms::placeholderFrame == frameType) { // create a continuing out of flow frame nsIFrame* oofFrame = nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame); diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index 935c4054bd5..b124708d59f 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -129,7 +129,9 @@ nsImageControlFrame::~nsImageControlFrame() void nsImageControlFrame::Destroy() { - nsFormControlFrame::RegUnRegAccessKey(static_cast(this), PR_FALSE); + if (!GetPrevInFlow()) { + nsFormControlFrame::RegUnRegAccessKey(this, PR_FALSE); + } nsImageControlFrameSuper::Destroy(); } @@ -149,6 +151,10 @@ nsImageControlFrame::Init(nsIContent* aContent, // nsIntPoint allocation can fail, in which case we just set the property // to null, which is safe + if (aPrevInFlow) { + return NS_OK; + } + return mContent->SetProperty(nsGkAtoms::imageClickedPoint, new nsIntPoint(0, 0), IntPointDtorFunc); @@ -212,8 +218,8 @@ nsImageControlFrame::Reflow(nsPresContext* aPresContext, { DO_GLOBAL_REFLOW_COUNT("nsImageControlFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); - if (mState & NS_FRAME_FIRST_REFLOW) { - nsFormControlFrame::RegUnRegAccessKey(static_cast(this), PR_TRUE); + if (!GetPrevInFlow() && (mState & NS_FRAME_FIRST_REFLOW)) { + nsFormControlFrame::RegUnRegAccessKey(this, PR_TRUE); } return nsImageControlFrameSuper::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); } diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 42d347ecc60..aa880697394 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -834,12 +834,10 @@ nsImageFrame::Reflow(nsPresContext* aPresContext, ((loadStatus & imgIRequest::STATUS_SIZE_AVAILABLE) || (mState & IMAGE_SIZECONSTRAINED)) && NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight && aMetrics.height > aReflowState.availableHeight) { - // split an image frame but not an image control frame - if (nsGkAtoms::imageFrame == GetType()) { - // our desired height was greater than 0, so to avoid infinite splitting, use 1 pixel as the min - aMetrics.height = PR_MAX(nsPresContext::CSSPixelsToAppUnits(1), aReflowState.availableHeight); - aStatus = NS_FRAME_NOT_COMPLETE; - } + // our desired height was greater than 0, so to avoid infinite + // splitting, use 1 pixel as the min + aMetrics.height = PR_MAX(nsPresContext::CSSPixelsToAppUnits(1), aReflowState.availableHeight); + aStatus = NS_FRAME_NOT_COMPLETE; } aMetrics.mOverflowArea.SetRect(0, 0, aMetrics.width, aMetrics.height); diff --git a/mozilla/layout/reftests/bugs/409659-1-ref.html b/mozilla/layout/reftests/bugs/409659-1-ref.html new file mode 100644 index 00000000000..530b627a11c --- /dev/null +++ b/mozilla/layout/reftests/bugs/409659-1-ref.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/mozilla/layout/reftests/bugs/409659-1a.html b/mozilla/layout/reftests/bugs/409659-1a.html new file mode 100644 index 00000000000..1cdb5bda7bb --- /dev/null +++ b/mozilla/layout/reftests/bugs/409659-1a.html @@ -0,0 +1,7 @@ + + + + + + diff --git a/mozilla/layout/reftests/bugs/409659-1b.html b/mozilla/layout/reftests/bugs/409659-1b.html new file mode 100644 index 00000000000..5a4bd29f973 --- /dev/null +++ b/mozilla/layout/reftests/bugs/409659-1b.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/mozilla/layout/reftests/bugs/409659-1c.html b/mozilla/layout/reftests/bugs/409659-1c.html new file mode 100644 index 00000000000..c6ee371fa61 --- /dev/null +++ b/mozilla/layout/reftests/bugs/409659-1c.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/mozilla/layout/reftests/bugs/409659-1d.html b/mozilla/layout/reftests/bugs/409659-1d.html new file mode 100644 index 00000000000..c80c614ec5e --- /dev/null +++ b/mozilla/layout/reftests/bugs/409659-1d.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/mozilla/layout/reftests/bugs/reftest.list b/mozilla/layout/reftests/bugs/reftest.list index 34cd0203413..217c638775b 100644 --- a/mozilla/layout/reftests/bugs/reftest.list +++ b/mozilla/layout/reftests/bugs/reftest.list @@ -618,3 +618,7 @@ random == 403134-1.html 403134-1-ref.html # bug 405377 == 408782-1b.html 408782-1-ref.html == 408782-2a.html 408782-2-ref.html == 408782-2b.html 408782-2-ref.html +== 409659-1a.html 409659-1-ref.html +!= 409659-1b.html 409659-1-ref.html +!= 409659-1c.html 409659-1-ref.html +== 409659-1d.html 409659-1-ref.html