1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/nsListItemFrame.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsListItemFrame.h" 1.10 + 1.11 +#include "nsCOMPtr.h" 1.12 +#include "nsNameSpaceManager.h" 1.13 +#include "nsGkAtoms.h" 1.14 +#include "nsDisplayList.h" 1.15 +#include "nsBoxLayout.h" 1.16 +#include <algorithm> 1.17 + 1.18 +nsListItemFrame::nsListItemFrame(nsIPresShell* aPresShell, 1.19 + nsStyleContext* aContext, 1.20 + bool aIsRoot, 1.21 + nsBoxLayout* aLayoutManager) 1.22 + : nsGridRowLeafFrame(aPresShell, aContext, aIsRoot, aLayoutManager) 1.23 +{ 1.24 +} 1.25 + 1.26 +nsListItemFrame::~nsListItemFrame() 1.27 +{ 1.28 +} 1.29 + 1.30 +nsSize 1.31 +nsListItemFrame::GetPrefSize(nsBoxLayoutState& aState) 1.32 +{ 1.33 + nsSize size = nsBoxFrame::GetPrefSize(aState); 1.34 + DISPLAY_PREF_SIZE(this, size); 1.35 + 1.36 + // guarantee that our preferred height doesn't exceed the standard 1.37 + // listbox row height 1.38 + size.height = std::max(mRect.height, size.height); 1.39 + return size; 1.40 +} 1.41 + 1.42 +void 1.43 +nsListItemFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, 1.44 + const nsRect& aDirtyRect, 1.45 + const nsDisplayListSet& aLists) 1.46 +{ 1.47 + if (aBuilder->IsForEventDelivery()) { 1.48 + if (!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::allowevents, 1.49 + nsGkAtoms::_true, eCaseMatters)) 1.50 + return; 1.51 + } 1.52 + 1.53 + nsGridRowLeafFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists); 1.54 +} 1.55 + 1.56 +// Creation Routine /////////////////////////////////////////////////////////////////////// 1.57 + 1.58 +already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout(); 1.59 + 1.60 +nsIFrame* 1.61 +NS_NewListItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) 1.62 +{ 1.63 + nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout(); 1.64 + if (!layout) { 1.65 + return nullptr; 1.66 + } 1.67 + 1.68 + return new (aPresShell) nsListItemFrame(aPresShell, aContext, false, layout); 1.69 +} 1.70 + 1.71 +NS_IMPL_FRAMEARENA_HELPERS(nsListItemFrame)