diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 28861c7b029..d2c1573c647 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -4064,21 +4064,42 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, #endif } + nsCOMPtr gfxScrolledStyle; + aPresContext->ResolvePseudoStyleContextFor(aContent, + nsLayoutAtoms::selectScrolledContentPseudo, + gfxListStyle, PR_FALSE, + getter_AddRefs(gfxScrolledStyle)); + + // create the area frame we are scrolling flags = NS_BLOCK_SHRINK_WRAP | (aIsAbsolutelyPositioned?NS_BLOCK_SPACE_MGR:0); nsIFrame* scrolledFrame = nsnull; NS_NewSelectsAreaFrame(aPresShell, &scrolledFrame, flags); + nsIFrame* newScrollFrame = nsnull; + + + /* scroll frame */ +#ifdef NEWGFX_LIST_SCROLLFRAME + nsIStyleContext* newStyle = nsnull; + + // ok take the style context, the Select area frame to scroll,the listFrame, and its parent + // and build the scrollframe. + BuildScrollFrame(aPresShell, aPresContext, aState, aContent, gfxScrolledStyle, scrolledFrame, + listFrame, newScrollFrame, newStyle); + + gfxScrolledStyle = newStyle; + +#else + newScrollFrame = scrolledFrame; +#endif + + /* // resolve a style for our gfx scrollframe based on the list frames style - // resolve a style for our gfx scrollframe based on the list frames style - nsCOMPtr scrollFrameStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsLayoutAtoms::selectScrolledContentPseudo, - gfxListStyle, PR_FALSE, - getter_AddRefs(scrollFrameStyle)); - + InitAndRestoreFrame(aPresContext, aState, aContent, - listFrame, scrollFrameStyle, nsnull, scrolledFrame); + parentFrame, gfxScrolledStyle, nsnull, scrolledFrame); + */ // XXX Temporary for Bug 19416 { @@ -4093,8 +4114,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, // scrolledFrameStyleContext - The resolved style context of the scrolledframe you passed in. // this is not the style of the scrollFrame. - nsIFrame* newScrollFrame = nsnull; - nsFrameItems anonChildItems; // Create display and button frames from the combobox'es anonymous content CreateAnonymousFrames(aPresShell, aPresContext, nsHTMLAtoms::combobox, aState, aContent, comboboxFrame, @@ -4104,21 +4123,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, anonChildItems.childList); - /* scroll frame */ - -#ifdef NEWGFX_LIST_SCROLLFRAME - nsIStyleContext * scrolledFrameStyleContext = nsnull; - - // ok take the style context, the Select area frame to scroll,the listFrame, and its parent - // and build the scrollframe. - BuildScrollFrame(aPresShell, aPresContext, aState, aContent, scrollFrameStyle, scrolledFrame, - listFrame, newScrollFrame, scrolledFrameStyleContext); -#else - newScrollFrame = scrolledFrame; -#endif - - - // The area frame is a floater container PRBool haveFirstLetterStyle, haveFirstLineStyle; HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 9695d574773..2088a3b5cb5 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -59,6 +59,9 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "nsIScrollableFrame.h" +#include "nsIScrollableView.h" + +static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID); #include "nsIXULDocument.h" // Temporary fix for Bug 36558 @@ -505,6 +508,7 @@ nsComboboxControlFrame::ScrollIntoView(nsIPresContext* aPresContext) void nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) { + /* //XXX: This is temporary. It simulates a psuedo dropdown states by using a attribute selector // This will not be need if the event state supports active states for use with the dropdown list // Currently, the event state manager will reset the active state to the content which has focus @@ -517,6 +521,26 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) } else { mContent->UnsetAttribute(kNameSpaceID_None, activeAtom, PR_TRUE); } + */ + + nsIView* view = nsnull; + mDropdownFrame->GetView(mPresContext, &view); + nsCOMPtr viewManager; + view->GetViewManager(*getter_AddRefs(viewManager)); + + if (aShowPopup) { + nsRect rect; + mDropdownFrame->GetRect(rect); + viewManager->ResizeView(view, rect.width, rect.height); + nsIScrollableView* scrollingView; + if (NS_SUCCEEDED(view->QueryInterface(kScrollViewIID, (void**)&scrollingView))) { + scrollingView->ComputeScrollOffsets(PR_TRUE); + } + viewManager->SetViewVisibility(view, nsViewVisibility_kShow); + } else { + viewManager->SetViewVisibility(view, nsViewVisibility_kHide); + viewManager->ResizeView(view, 0, 0); + } } // Show the dropdown list @@ -586,15 +610,25 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame, availSize); kidReflowState.mComputedWidth = aAvailableWidth; kidReflowState.mComputedHeight = aAvailableHeight; - + + // ensure we start off hidden + if (aReflowState.reason == eReflowReason_Initial) { + nsIView* view = nsnull; + mDropdownFrame->GetView(mPresContext, &view); + nsCOMPtr viewManager; + view->GetViewManager(*getter_AddRefs(viewManager)); + viewManager->SetViewVisibility(view, nsViewVisibility_kHide); + viewManager->ResizeView(view, 0, 0); + } + // Reflow child nsRect rect; aFrame->GetRect(rect); nsresult rv = ReflowChild(aFrame, aPresContext, aDesiredSize, kidReflowState, - rect.x, rect.y, 0, aStatus); + rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW |NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_VISIBILITY, aStatus); // Set the child's width and height to it's desired size - FinishReflowChild(aFrame, aPresContext, aDesiredSize, rect.x, rect.y, 0); + FinishReflowChild(aFrame, aPresContext, aDesiredSize, rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW |NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_VISIBILITY); return rv; } diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 14e56328603..22f4e307e53 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -949,13 +949,13 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, { // check whether style allows selection // if not dont tell selection the mouse event even occured. + + if (!IsSelectable(this)) + return NS_OK; if (!IsMouseCaptured(aPresContext)) CaptureMouse(aPresContext, PR_TRUE); - if (!IsSelectable(this)) - return NS_OK; - PRInt16 displayresult = nsISelectionController::SELECTION_OFF; nsresult rv; nsCOMPtr selCon; diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 4e9d953972f..c0ad657ef6d 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -610,6 +610,8 @@ nsGfxScrollFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize) if (styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL || styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL) { + // make sure they are visible. + mInner->SetScrollbarVisibility(mInner->mVScrollbarBox, PR_TRUE); nsSize vSize(0,0); mInner->mVScrollbarBox->GetPrefSize(aState, vSize); nsBox::AddMargin(mInner->mVScrollbarBox, vSize); @@ -620,6 +622,7 @@ nsGfxScrollFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize) if (styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL || styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL) { nsSize hSize(0,0); + mInner->SetScrollbarVisibility(mInner->mHScrollbarBox, PR_TRUE); mInner->mHScrollbarBox->GetPrefSize(aState, hSize); nsBox::AddMargin(mInner->mHScrollbarBox, hSize); diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 14e56328603..22f4e307e53 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -949,13 +949,13 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, { // check whether style allows selection // if not dont tell selection the mouse event even occured. + + if (!IsSelectable(this)) + return NS_OK; if (!IsMouseCaptured(aPresContext)) CaptureMouse(aPresContext, PR_TRUE); - if (!IsSelectable(this)) - return NS_OK; - PRInt16 displayresult = nsISelectionController::SELECTION_OFF; nsresult rv; nsCOMPtr selCon; diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index 4e9d953972f..c0ad657ef6d 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -610,6 +610,8 @@ nsGfxScrollFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize) if (styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL || styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL) { + // make sure they are visible. + mInner->SetScrollbarVisibility(mInner->mVScrollbarBox, PR_TRUE); nsSize vSize(0,0); mInner->mVScrollbarBox->GetPrefSize(aState, vSize); nsBox::AddMargin(mInner->mVScrollbarBox, vSize); @@ -620,6 +622,7 @@ nsGfxScrollFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize) if (styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL || styleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL) { nsSize hSize(0,0); + mInner->SetScrollbarVisibility(mInner->mHScrollbarBox, PR_TRUE); mInner->mHScrollbarBox->GetPrefSize(aState, hSize); nsBox::AddMargin(mInner->mHScrollbarBox, hSize); diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 033d8af3ed9..bad03e55b31 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -163,6 +163,13 @@ nsScrollFrame::GetScrollPreference(nsIPresContext* aPresContext, nsScrollPref* a case nsScrollPreference_kAlwaysScroll: *aScrollPreference = AlwaysScroll; break; + case nsScrollPreference_kAlwaysScrollHorizontal: + *aScrollPreference = AlwaysScrollHorizontal; + break; + case nsScrollPreference_kAlwaysScrollVertical: + *aScrollPreference = AlwaysScrollVertical; + break; + } return NS_OK; @@ -438,9 +445,25 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext) scrollingView->CreateScrollControls(); // Set the scrolling view's scroll preference - nsScrollPreference scrollPref = (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) - ? nsScrollPreference_kAlwaysScroll : - nsScrollPreference_kAuto; + nsScrollPreference scrollPref; + + switch (display->mOverflow) + { + case NS_STYLE_OVERFLOW_SCROLL: + scrollPref = nsScrollPreference_kAlwaysScroll; + break; + + case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL: + scrollPref = nsScrollPreference_kAlwaysScrollHorizontal; + break; + + case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL: + scrollPref = nsScrollPreference_kAlwaysScrollVertical; + break; + + default: + scrollPref = nsScrollPreference_kAuto; + } // If this is a scroll frame for a viewport and its webshell // has its scrolling set, use that value @@ -533,7 +556,7 @@ nsScrollFrame::CalculateScrollAreaSize(nsIPresContext* aPresContext, } // See whether we have 'auto' scrollbars - if (aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL) { + if (aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL || aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL) { // Always show both scrollbars, so subtract for the space taken up by the // vertical scrollbar if (!unconstrainedWidth) { @@ -575,7 +598,7 @@ nsScrollFrame::CalculateScrollAreaSize(nsIPresContext* aPresContext, // If scrollbars are always visible, then subtract for the height of the // horizontal scrollbar - if ((NS_STYLE_OVERFLOW_SCROLL == aReflowState.mStyleDisplay->mOverflow) && + if ((NS_STYLE_OVERFLOW_SCROLL == aReflowState.mStyleDisplay->mOverflow || aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL) && !unconstrainedWidth) { aScrollAreaSize->height -= aSBHeight; } @@ -775,35 +798,38 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext, PRBool mustReflow = PR_FALSE; - // There are two cases to consider - if (roomForVerticalScrollbar) { - if (kidDesiredSize.height <= scrollAreaSize.height) { - // We left room for the vertical scrollbar, but it's not needed; - // reflow with a larger computed width - // XXX We need to be checking for horizontal scrolling... - kidReflowState.availableWidth += sbWidth; - kidReflowState.mComputedWidth += sbWidth; - scrollAreaSize.width += sbWidth; - mustReflow = PR_TRUE; -#ifdef NOISY_SECOND_REFLOW - ListTag(stdout); - printf(": kid-height=%d < scrollArea-height=%d\n", - kidDesiredSize.height, scrollAreaSize.height); -#endif - } - } else { - if (kidDesiredSize.height > scrollAreaSize.height) { - // We didn't leave room for the vertical scrollbar, but it turns - // out we needed it - kidReflowState.availableWidth -= sbWidth; - kidReflowState.mComputedWidth -= sbWidth; - scrollAreaSize.width -= sbWidth; - mustReflow = PR_TRUE; -#ifdef NOISY_SECOND_REFLOW - ListTag(stdout); - printf(": kid-height=%d > scrollArea-height=%d\n", - kidDesiredSize.height, scrollAreaSize.height); -#endif + if (aReflowState.mStyleDisplay->mOverflow != NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL) + { + // There are two cases to consider + if (roomForVerticalScrollbar) { + if (kidDesiredSize.height <= scrollAreaSize.height) { + // We left room for the vertical scrollbar, but it's not needed; + // reflow with a larger computed width + // XXX We need to be checking for horizontal scrolling... + kidReflowState.availableWidth += sbWidth; + kidReflowState.mComputedWidth += sbWidth; + scrollAreaSize.width += sbWidth; + mustReflow = PR_TRUE; + #ifdef NOISY_SECOND_REFLOW + ListTag(stdout); + printf(": kid-height=%d < scrollArea-height=%d\n", + kidDesiredSize.height, scrollAreaSize.height); + #endif + } + } else { + if (kidDesiredSize.height > scrollAreaSize.height) { + // We didn't leave room for the vertical scrollbar, but it turns + // out we needed it + kidReflowState.availableWidth -= sbWidth; + kidReflowState.mComputedWidth -= sbWidth; + scrollAreaSize.width -= sbWidth; + mustReflow = PR_TRUE; + #ifdef NOISY_SECOND_REFLOW + ListTag(stdout); + printf(": kid-height=%d > scrollArea-height=%d\n", + kidDesiredSize.height, scrollAreaSize.height); + #endif + } } } @@ -829,22 +855,27 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext, } } - // Make sure the height of the scrolled frame fills the entire scroll area, - // unless we're shrink wrapping - if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) { - if (kidDesiredSize.height < scrollAreaSize.height) { - kidDesiredSize.height = scrollAreaSize.height; + if (aReflowState.mStyleDisplay->mOverflow != NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL) + { - // If there's an auto horizontal scrollbar and the scrollbar will be - // visible then subtract for the space taken up by the scrollbar; - // otherwise, we'll end up with a vertical scrollbar even if we don't - // need one... - if ((NS_STYLE_OVERFLOW_SCROLL != aReflowState.mStyleDisplay->mOverflow) && - (kidDesiredSize.width > scrollAreaSize.width)) { - kidDesiredSize.height -= sbHeight; + // Make sure the height of the scrolled frame fills the entire scroll area, + // unless we're shrink wrapping + if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) { + if (kidDesiredSize.height < scrollAreaSize.height) { + kidDesiredSize.height = scrollAreaSize.height; + + // If there's an auto horizontal scrollbar and the scrollbar will be + // visible then subtract for the space taken up by the scrollbar; + // otherwise, we'll end up with a vertical scrollbar even if we don't + // need one... + if ((NS_STYLE_OVERFLOW_SCROLL != aReflowState.mStyleDisplay->mOverflow && aReflowState.mStyleDisplay->mOverflow != NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL) && + (kidDesiredSize.width > scrollAreaSize.width)) { + kidDesiredSize.height -= sbHeight; + } } } } + // Make sure the width of the scrolled frame fills the entire scroll area if (kidDesiredSize.width < scrollAreaSize.width) { kidDesiredSize.width = scrollAreaSize.width; @@ -862,7 +893,7 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext, aDesiredSize.width += border.left + border.right; if ((kidDesiredSize.height > scrollAreaSize.height) || - (aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL)) { + (aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLL || aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL)) { aDesiredSize.width += sbWidth; } @@ -876,7 +907,7 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext, } aDesiredSize.height += border.top + border.bottom; // XXX This should really be "if we have a visible horizontal scrollbar"... - if (NS_STYLE_OVERFLOW_SCROLL == aReflowState.mStyleDisplay->mOverflow) { + if (NS_STYLE_OVERFLOW_SCROLL == aReflowState.mStyleDisplay->mOverflow || aReflowState.mStyleDisplay->mOverflow == NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL) { aDesiredSize.height += sbHeight; } diff --git a/mozilla/layout/html/document/src/html.css b/mozilla/layout/html/document/src/html.css index 8826d7832ff..791169b4be8 100644 --- a/mozilla/layout/html/document/src/html.css +++ b/mozilla/layout/html/document/src/html.css @@ -1183,9 +1183,7 @@ sourcetext { /* XXX should not be in HTML namespace */ } :-moz-select-scrolled-content { - background: inherit; - display: inherit; - padding: inherit; + overflow: -moz-scrollbars-vertical ! important; } :scrolled-content { @@ -1301,14 +1299,15 @@ sourcetext { /* XXX should not be in HTML namespace */ /* combobox dropdown list hidden */ select:-moz-dropdown-list { - visibility:collapse; + z-index: 2147483647; } -/* combobox dropdown list visible */ +/* combobox dropdown list visible select[-moz-dropdown-active]:-moz-dropdown-list { visibility: visible; z-index: 2147483647; } +*/ :-moz-anonymous-block { display: block; diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 9695d574773..2088a3b5cb5 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -59,6 +59,9 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "nsIScrollableFrame.h" +#include "nsIScrollableView.h" + +static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID); #include "nsIXULDocument.h" // Temporary fix for Bug 36558 @@ -505,6 +508,7 @@ nsComboboxControlFrame::ScrollIntoView(nsIPresContext* aPresContext) void nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) { + /* //XXX: This is temporary. It simulates a psuedo dropdown states by using a attribute selector // This will not be need if the event state supports active states for use with the dropdown list // Currently, the event state manager will reset the active state to the content which has focus @@ -517,6 +521,26 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) } else { mContent->UnsetAttribute(kNameSpaceID_None, activeAtom, PR_TRUE); } + */ + + nsIView* view = nsnull; + mDropdownFrame->GetView(mPresContext, &view); + nsCOMPtr viewManager; + view->GetViewManager(*getter_AddRefs(viewManager)); + + if (aShowPopup) { + nsRect rect; + mDropdownFrame->GetRect(rect); + viewManager->ResizeView(view, rect.width, rect.height); + nsIScrollableView* scrollingView; + if (NS_SUCCEEDED(view->QueryInterface(kScrollViewIID, (void**)&scrollingView))) { + scrollingView->ComputeScrollOffsets(PR_TRUE); + } + viewManager->SetViewVisibility(view, nsViewVisibility_kShow); + } else { + viewManager->SetViewVisibility(view, nsViewVisibility_kHide); + viewManager->ResizeView(view, 0, 0); + } } // Show the dropdown list @@ -586,15 +610,25 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame, availSize); kidReflowState.mComputedWidth = aAvailableWidth; kidReflowState.mComputedHeight = aAvailableHeight; - + + // ensure we start off hidden + if (aReflowState.reason == eReflowReason_Initial) { + nsIView* view = nsnull; + mDropdownFrame->GetView(mPresContext, &view); + nsCOMPtr viewManager; + view->GetViewManager(*getter_AddRefs(viewManager)); + viewManager->SetViewVisibility(view, nsViewVisibility_kHide); + viewManager->ResizeView(view, 0, 0); + } + // Reflow child nsRect rect; aFrame->GetRect(rect); nsresult rv = ReflowChild(aFrame, aPresContext, aDesiredSize, kidReflowState, - rect.x, rect.y, 0, aStatus); + rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW |NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_VISIBILITY, aStatus); // Set the child's width and height to it's desired size - FinishReflowChild(aFrame, aPresContext, aDesiredSize, rect.x, rect.y, 0); + FinishReflowChild(aFrame, aPresContext, aDesiredSize, rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW |NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_VISIBILITY); return rv; } diff --git a/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp index 19cd902d043..c5e582b86f5 100644 --- a/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp @@ -475,6 +475,7 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, nsIFrame * firstChildFrame = nsnull; FirstChild(aPresContext, nsnull, &firstChildFrame); + /* // XXX So this may do it too often // the side effect of this is if the user has scrolled to some other place in the list and // an incremental reflow comes through the list gets scrolled to the first selected item @@ -592,6 +593,42 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, } } } + */ + + if (aReflowState.reason == eReflowReason_Incremental) + { + if (aReflowState.reflowCommand) { + nsIFrame* incrementalChild = nsnull; + aReflowState.reflowCommand->GetNext(incrementalChild); + + NS_ASSERTION(incrementalChild == firstChildFrame || !incrementalChild, "Child is not in our list!!"); + + if (!incrementalChild) { + nsIFrame* target; + aReflowState.reflowCommand->GetTarget(target); + NS_ASSERTION(target == this, "Not our target!"); + + nsIReflowCommand::ReflowType type; + aReflowState.reflowCommand->GetType(type); + switch (type) { + case nsIReflowCommand::StyleChanged: { + nsHTMLReflowState newState(aReflowState); + newState.reason = eReflowReason_StyleChange; + newState.reflowCommand = nsnull; + return Reflow(aPresContext, aDesiredSize, newState, aStatus); + } + case nsIReflowCommand::ReflowDirty: { + nsHTMLReflowState newState(aReflowState); + newState.reason = eReflowReason_Dirty; + newState.reflowCommand = nsnull; + return Reflow(aPresContext, aDesiredSize, newState, aStatus); + } + default: + NS_ERROR("Unknown incremental reflow type"); + } + } + } + } // Strategy: Let the inherited reflow happen as though the width and height of the // ScrollFrame are big enough to allow the listbox to @@ -657,19 +694,20 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, printf("After1st DW: %d DH: %d\n", scrolledAreaDesiredSize.width, scrolledAreaDesiredSize.height); nsIScrollableFrame * scrollableFrame = nsnull; - nsRect scrolledRect; + + /* + nscoord scrollbarWidth = 0; + nscoord scrollbarHeight = 0; if (NS_SUCCEEDED(firstChildFrame->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollableFrame))) { - nsIFrame * scrolledFrame; - scrollableFrame->GetScrolledFrame(aPresContext, scrolledFrame); - NS_ASSERTION(scrolledFrame != nsnull, "Must have scrollable frame"); - scrolledFrame->GetRect(scrolledRect); + scrollableFrame->GetScrollbarSizes(aPresContext, &scrollbarWidth, &scrollbarHeight); } else { NS_ASSERTION(scrollableFrame != nsnull, "Must have scrollableFrame frame"); } + */ // The nsScrollFrame::REflow adds in the scrollbar width and border dimensions // to the maxElementSize, so these need to be subtracted - nscoord scrolledAreaWidth = scrolledAreaDesiredSize.maxElementSize->width; + nscoord scrolledAreaWidth = scrolledAreaDesiredSize.width; //maxElementSize->width; nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height; // Keep the oringal values @@ -679,6 +717,7 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, // The first reflow produces a box with the scrollbar width and borders // added in so we need to subtract them out. + /* // Retrieve the scrollbar's width and height float sbWidth = 0.0; float sbHeight = 0.0;; @@ -689,6 +728,7 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, nscoord scrollbarWidth = NSToCoordRound(sbWidth); //nscoord scrollbarHeight = NSToCoordRound(sbHeight); +*/ // Subtract out the borders nsMargin border; @@ -712,8 +752,7 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, mMaxWidth -= (scrollBorderPadding.left + scrollBorderPadding.right); mMaxHeight -= (scrollBorderPadding.top + scrollBorderPadding.bottom); - - // Now the scrolledAreaWidth and scrolledAreaHeight are exactly + // Now the scrolledAreaWidth and scrolledAreaHeight are exactly // wide and high enough to enclose their contents scrolledAreaWidth -= (scrollBorderPadding.left + scrollBorderPadding.right); @@ -723,7 +762,7 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, if (isInDropDownMode) { if (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth) { visibleWidth = scrolledAreaWidth; - visibleWidth += scrollbarWidth; + //visibleWidth += scrollbarWidth; } else { visibleWidth = aReflowState.mComputedWidth; visibleWidth -= (scrollBorderPadding.left + scrollBorderPadding.right); @@ -731,7 +770,6 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, } else { if (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth) { visibleWidth = scrolledAreaWidth; - //visibleWidth += scrollbarWidth; } else { visibleWidth = aReflowState.mComputedWidth; } @@ -899,14 +937,19 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, mCachedScrollFrameSize.width = visibleWidth; mCachedScrollFrameSize.height = visibleHeight; // Reflow + firstChildFrame->WillReflow(aPresContext); firstChildFrame->MoveTo(aPresContext, aReflowState.mComputedBorderPadding.left, aReflowState.mComputedBorderPadding.top); + + /* nsIView* view; firstChildFrame->GetView(aPresContext, &view); NS_ASSERTION(view == nsnull, "Hmmmm, fix this!"); if (view) { nsContainerFrame::PositionFrameView(aPresContext, firstChildFrame, view); } + */ + firstChildFrame->Reflow(aPresContext, scrolledAreaDesiredSize, secondPassState, @@ -918,6 +961,8 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, //mCachedScrollFrameSize.width = scrolledAreaDesiredSize.width; //mCachedScrollFrameSize.height = scrolledAreaDesiredSize.height; + // if we had no scrollbar before and now we have one + // then reflow again with the new scrollbar. nsMargin b = aReflowState.mComputedBorderPadding - aReflowState.mComputedPadding; diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 28861c7b029..d2c1573c647 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -4064,21 +4064,42 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, #endif } + nsCOMPtr gfxScrolledStyle; + aPresContext->ResolvePseudoStyleContextFor(aContent, + nsLayoutAtoms::selectScrolledContentPseudo, + gfxListStyle, PR_FALSE, + getter_AddRefs(gfxScrolledStyle)); + + // create the area frame we are scrolling flags = NS_BLOCK_SHRINK_WRAP | (aIsAbsolutelyPositioned?NS_BLOCK_SPACE_MGR:0); nsIFrame* scrolledFrame = nsnull; NS_NewSelectsAreaFrame(aPresShell, &scrolledFrame, flags); + nsIFrame* newScrollFrame = nsnull; + + + /* scroll frame */ +#ifdef NEWGFX_LIST_SCROLLFRAME + nsIStyleContext* newStyle = nsnull; + + // ok take the style context, the Select area frame to scroll,the listFrame, and its parent + // and build the scrollframe. + BuildScrollFrame(aPresShell, aPresContext, aState, aContent, gfxScrolledStyle, scrolledFrame, + listFrame, newScrollFrame, newStyle); + + gfxScrolledStyle = newStyle; + +#else + newScrollFrame = scrolledFrame; +#endif + + /* // resolve a style for our gfx scrollframe based on the list frames style - // resolve a style for our gfx scrollframe based on the list frames style - nsCOMPtr scrollFrameStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsLayoutAtoms::selectScrolledContentPseudo, - gfxListStyle, PR_FALSE, - getter_AddRefs(scrollFrameStyle)); - + InitAndRestoreFrame(aPresContext, aState, aContent, - listFrame, scrollFrameStyle, nsnull, scrolledFrame); + parentFrame, gfxScrolledStyle, nsnull, scrolledFrame); + */ // XXX Temporary for Bug 19416 { @@ -4093,8 +4114,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, // scrolledFrameStyleContext - The resolved style context of the scrolledframe you passed in. // this is not the style of the scrollFrame. - nsIFrame* newScrollFrame = nsnull; - nsFrameItems anonChildItems; // Create display and button frames from the combobox'es anonymous content CreateAnonymousFrames(aPresShell, aPresContext, nsHTMLAtoms::combobox, aState, aContent, comboboxFrame, @@ -4104,21 +4123,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, anonChildItems.childList); - /* scroll frame */ - -#ifdef NEWGFX_LIST_SCROLLFRAME - nsIStyleContext * scrolledFrameStyleContext = nsnull; - - // ok take the style context, the Select area frame to scroll,the listFrame, and its parent - // and build the scrollframe. - BuildScrollFrame(aPresShell, aPresContext, aState, aContent, scrollFrameStyle, scrolledFrame, - listFrame, newScrollFrame, scrolledFrameStyleContext); -#else - newScrollFrame = scrolledFrame; -#endif - - - // The area frame is a floater container PRBool haveFirstLetterStyle, haveFirstLineStyle; HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, diff --git a/mozilla/layout/style/html.css b/mozilla/layout/style/html.css index 8826d7832ff..791169b4be8 100644 --- a/mozilla/layout/style/html.css +++ b/mozilla/layout/style/html.css @@ -1183,9 +1183,7 @@ sourcetext { /* XXX should not be in HTML namespace */ } :-moz-select-scrolled-content { - background: inherit; - display: inherit; - padding: inherit; + overflow: -moz-scrollbars-vertical ! important; } :scrolled-content { @@ -1301,14 +1299,15 @@ sourcetext { /* XXX should not be in HTML namespace */ /* combobox dropdown list hidden */ select:-moz-dropdown-list { - visibility:collapse; + z-index: 2147483647; } -/* combobox dropdown list visible */ +/* combobox dropdown list visible select[-moz-dropdown-active]:-moz-dropdown-list { visibility: visible; z-index: 2147483647; } +*/ :-moz-anonymous-block { display: block; diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index e14f079f9fa..f4f165f0d54 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -130,8 +130,8 @@ public: ResizeType GetResizeAfter(); State GetState(); - nsresult CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents); - PRBool IsMouseCaptured(nsIPresContext* aPresContext); + //nsresult CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents); + //PRBool IsMouseCaptured(nsIPresContext* aPresContext); void Reverse(nsSplitterInfo*& aIndexes, PRInt32 aCount); CollapseDirection GetCollapseDirection(); @@ -248,6 +248,7 @@ nsSplitterFrame::~nsSplitterFrame() mInner->Release(); } + // // QueryInterface // @@ -379,10 +380,18 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext, NS_IMETHODIMP nsSplitterFrame::Layout(nsBoxLayoutState& aState) { - if (aState.GetLayoutReason() == nsBoxLayoutState::Initial) { + nsIFrame* frame; + GetFrame(&frame); + + nsFrameState childState; + frame->GetFrameState(&childState); + + if (childState & NS_FRAME_FIRST_REFLOW) + { GetParentBox(&mInner->mParentBox); mInner->UpdateState(); } + return nsBoxFrame::Layout(aState); } @@ -448,7 +457,7 @@ NS_IMETHODIMP nsSplitterFrame::GetFrameForPoint(nsIPresContext* aPresContext, return NS_ERROR_FAILURE; // if the mouse is captured always return us as the frame. - if (mInner->IsMouseCaptured(aPresContext)) + if (IsMouseCaptured(aPresContext)) { // XXX It's probably better not to check visibility here, right? *aFrame = this; @@ -489,10 +498,10 @@ nsSplitterFrame::HandleEvent(nsIPresContext* aPresContext, void nsSplitterFrameInner::MouseUp(nsIPresContext* aPresContext, nsGUIEvent* aEvent) { - if (IsMouseCaptured(aPresContext)) { + if (mOuter->IsMouseCaptured(aPresContext)) { AdjustChildren(aPresContext); AddListener(aPresContext); - CaptureMouse(aPresContext, PR_FALSE); + mOuter->CaptureMouse(aPresContext, PR_FALSE); State newState = GetState(); // if the state is dragging then make it Open. if (newState == Dragging) @@ -508,7 +517,7 @@ nsSplitterFrameInner::MouseUp(nsIPresContext* aPresContext, nsGUIEvent* aEvent) void nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent) { - if (IsMouseCaptured(aPresContext)) { + if (mOuter->IsMouseCaptured(aPresContext)) { //printf("Dragging\n"); @@ -675,6 +684,7 @@ nsSplitterFrameInner::RemoveListener() reciever->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMMouseMotionListener*,this),NS_GET_IID(nsIDOMMouseMotionListener)); } +/* nsresult nsSplitterFrameInner :: CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents) { @@ -704,6 +714,7 @@ nsSplitterFrameInner :: CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabM return NS_OK; } + PRBool nsSplitterFrameInner :: IsMouseCaptured(nsIPresContext* aPresContext) { @@ -725,6 +736,7 @@ nsSplitterFrameInner :: IsMouseCaptured(nsIPresContext* aPresContext) return PR_FALSE; } +*/ nsresult nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent) @@ -896,13 +908,13 @@ nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent) if (!mPressed) return NS_OK; - if (IsMouseCaptured(mOuter->mPresContext)) + if (mOuter->IsMouseCaptured(mOuter->mPresContext)) return NS_OK; mOuter->mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::state, NS_ConvertASCIItoUCS2("dragging"), PR_TRUE); RemoveListener(); - CaptureMouse(mOuter->mPresContext, PR_TRUE); + mOuter->CaptureMouse(mOuter->mPresContext, PR_TRUE); return NS_OK; } diff --git a/mozilla/view/public/nsIScrollableView.h b/mozilla/view/public/nsIScrollableView.h index 9713506a9b5..23170d89cfc 100644 --- a/mozilla/view/public/nsIScrollableView.h +++ b/mozilla/view/public/nsIScrollableView.h @@ -33,7 +33,9 @@ class nsIScrollPositionListener; typedef enum { nsScrollPreference_kAuto = 0, nsScrollPreference_kNeverScroll, - nsScrollPreference_kAlwaysScroll + nsScrollPreference_kAlwaysScroll, + nsScrollPreference_kAlwaysScrollHorizontal, + nsScrollPreference_kAlwaysScrollVertical } nsScrollPreference; // IID for the nsIScrollableView interface diff --git a/mozilla/view/src/nsScrollingView.cpp b/mozilla/view/src/nsScrollingView.cpp index 2a1f5f87a99..922ba20f194 100644 --- a/mozilla/view/src/nsScrollingView.cpp +++ b/mozilla/view/src/nsScrollingView.cpp @@ -986,7 +986,8 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets) if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) { if (((mSizeX > controlRect.width) && (mScrollPref != nsScrollPreference_kNeverScroll)) || - (mScrollPref == nsScrollPreference_kAlwaysScroll)) + (mScrollPref == nsScrollPreference_kAlwaysScroll) || + (mScrollPref == nsScrollPreference_kAlwaysScrollHorizontal)) { hasHorizontal = PR_TRUE; } @@ -1052,7 +1053,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets) scrollv->SetPosition(0); // make sure thumb is at the top - if (mScrollPref == nsScrollPreference_kAlwaysScroll) + if (mScrollPref == nsScrollPreference_kAlwaysScroll || mScrollPref == nsScrollPreference_kAlwaysScrollVertical) { ((ScrollBarView *)mVScrollBarView)->SetEnabled(PR_TRUE); win->Enable(PR_FALSE); @@ -1124,7 +1125,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets) scrollh->SetPosition(0); // make sure thumb is all the way to the left - if (mScrollPref == nsScrollPreference_kAlwaysScroll) + if (mScrollPref == nsScrollPreference_kAlwaysScroll || mScrollPref == nsScrollPreference_kAlwaysScrollHorizontal) { ((ScrollBarView *)mHScrollBarView)->SetEnabled(PR_TRUE); win->Enable(PR_FALSE); diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index b01e401c441..94f6c4f961c 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -855,10 +855,11 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition() /* You would think that doing a move and resize all in one operation would * be faster but its not. Something is really broken here. So I'm comenting - * this out for now + * this out for now // if we moved and resized do it all in one shot if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED && mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED) { + nscoord parx = 0, pary = 0; nsIWidget *pwidget = nsnull; @@ -877,14 +878,14 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition() else if (bounds.width == width && bounds.height == bounds.height) mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED; else { + printf("%d) SetBounds(%d,%d,%d,%d)\n", this, x, y, width, height); mWindow->Resize(x,y,width,height, PR_TRUE); mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED; mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED; return NS_OK; } } - */ - + */ // if we just resized do it if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED) { @@ -895,8 +896,10 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition() nsRect bounds; mWindow->GetBounds(bounds); - if (bounds.width != width || bounds.height != bounds.height) + if (bounds.width != width || bounds.height != bounds.height) { + printf("%d) Resize(%d,%d)\n", this, width, height); mWindow->Resize(width,height, PR_TRUE); + } mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED; } @@ -915,8 +918,10 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition() nsRect bounds; mWindow->GetBounds(bounds); - if (bounds.x != x || bounds.y != y) + if (bounds.x != x || bounds.y != y) { + printf("%d) Move(%d,%d)\n", this, x, y); mWindow->Move(x,y); + } mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED; } diff --git a/mozilla/view/src/nsViewManager2.cpp b/mozilla/view/src/nsViewManager2.cpp index b9b29104016..8af6215dbcf 100755 --- a/mozilla/view/src/nsViewManager2.cpp +++ b/mozilla/view/src/nsViewManager2.cpp @@ -2814,6 +2814,7 @@ nsViewManager2::CacheWidgetChanges(PRBool aCache) nsresult nsViewManager2::ProcessWidgetChanges(nsIView* aView) { + //printf("---------Begin Sync----------\n"); nsresult rv = aView->SynchWidgetSizePosition(); if (NS_FAILED(rv)) return rv; @@ -2828,6 +2829,8 @@ nsViewManager2::ProcessWidgetChanges(nsIView* aView) child->GetNextSibling(child); } + //printf("---------End Sync----------\n"); + return NS_OK; } diff --git a/mozilla/xpfe/global/resources/skin/xul.css b/mozilla/xpfe/global/resources/skin/xul.css index bac37043090..49bb8403902 100644 --- a/mozilla/xpfe/global/resources/skin/xul.css +++ b/mozilla/xpfe/global/resources/skin/xul.css @@ -12,6 +12,7 @@ * { display: block; + user-select: none; } *[collapsed="true"] {