layout/xul/grid/nsGridRowLeafFrame.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //
     7 // Eric Vaughan
     8 // Netscape Communications
     9 //
    10 // See documentation in associated header file
    11 //
    13 #include "nsGridRowLeafFrame.h"
    14 #include "nsGridRowLeafLayout.h"
    15 #include "nsGridRow.h"
    16 #include "nsBoxLayoutState.h"
    17 #include "nsGridLayout2.h"
    19 already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
    21 nsIFrame*
    22 NS_NewGridRowLeafFrame(nsIPresShell* aPresShell,
    23                        nsStyleContext* aContext)
    24 {
    25   nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
    26   return new (aPresShell) nsGridRowLeafFrame(aPresShell, aContext, false,
    27                                              layout);
    28 }
    30 NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame)
    32 /*
    33  * Our border and padding could be affected by our columns or rows.
    34  * Let's go check it out.
    35  */
    36 nsresult
    37 nsGridRowLeafFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
    38 {
    39   // if our columns have made our padding larger add it in.
    40   nsresult rv = nsBoxFrame::GetBorderAndPadding(aBorderAndPadding);
    42   nsIGridPart* part = nsGrid::GetPartFromBox(this);
    43   if (!part)
    44     return rv;
    46   int32_t index = 0;
    47   nsGrid* grid = part->GetGrid(this, &index);
    49   if (!grid) 
    50     return rv;
    52   bool isHorizontal = IsHorizontal();
    54   nsBoxLayoutState state(PresContext());
    56   int32_t firstIndex = 0;
    57   int32_t lastIndex = 0;
    58   nsGridRow* firstRow = nullptr;
    59   nsGridRow* lastRow = nullptr;
    60   grid->GetFirstAndLastRow(state, firstIndex, lastIndex, firstRow, lastRow, isHorizontal);
    62   // only the first and last rows can be affected.
    63   if (firstRow && firstRow->GetBox() == this) {
    65     nscoord top = 0;
    66     nscoord bottom = 0;
    67     grid->GetRowOffsets(state, firstIndex, top, bottom, isHorizontal);
    69     if (isHorizontal) {
    70       if (top > aBorderAndPadding.top)
    71         aBorderAndPadding.top = top;
    72     } else {
    73       if (top > aBorderAndPadding.left)
    74         aBorderAndPadding.left = top;
    75     } 
    76   }
    78   if (lastRow && lastRow->GetBox() == this) {
    80     nscoord top = 0;
    81     nscoord bottom = 0;
    82     grid->GetRowOffsets(state, lastIndex, top, bottom, isHorizontal);
    84     if (isHorizontal) {
    85       if (bottom > aBorderAndPadding.bottom)
    86         aBorderAndPadding.bottom = bottom;
    87     } else {
    88       if (bottom > aBorderAndPadding.right)
    89         aBorderAndPadding.right = bottom;
    90     }
    92   }  
    94   return rv;
    95 }

mercurial