layout/xul/grid/nsGridCell.cpp

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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 "nsGridCell.h"
    14 #include "nsFrame.h"
    15 #include "nsBox.h"
    16 #include "nsGridLayout2.h"
    19 nsGridCell::nsGridCell():mBoxInColumn(nullptr),mBoxInRow(nullptr)
    20 {
    21     MOZ_COUNT_CTOR(nsGridCell);
    22 }                                               
    24 nsGridCell::~nsGridCell()
    25 {
    26     MOZ_COUNT_DTOR(nsGridCell);
    27 }
    29 nsSize
    30 nsGridCell::GetPrefSize(nsBoxLayoutState& aState)
    31 {
    32   nsSize sum(0,0);
    34   // take our 2 children and add them up.
    35   // we are as wide as the widest child plus its left offset
    36   // we are tall as the tallest child plus its top offset
    38   if (mBoxInColumn) {
    39     nsSize pref = mBoxInColumn->GetPrefSize(aState);
    41     nsBox::AddMargin(mBoxInColumn, pref);
    42     nsGridLayout2::AddOffset(aState, mBoxInColumn, pref);
    44     nsBoxLayout::AddLargestSize(sum, pref);
    45   }
    47   if (mBoxInRow) {
    48     nsSize pref = mBoxInRow->GetPrefSize(aState);
    50     nsBox::AddMargin(mBoxInRow, pref);
    51     nsGridLayout2::AddOffset(aState, mBoxInRow, pref);
    53     nsBoxLayout::AddLargestSize(sum, pref);
    54   }
    56   return sum;
    57 }
    59 nsSize
    60 nsGridCell::GetMinSize(nsBoxLayoutState& aState)
    61 {
    62   nsSize sum(0, 0);
    64   // take our 2 children and add them up.
    65   // we are as wide as the widest child plus its left offset
    66   // we are tall as the tallest child plus its top offset
    68   if (mBoxInColumn) {
    69     nsSize min = mBoxInColumn->GetMinSize(aState);
    71     nsBox::AddMargin(mBoxInColumn, min);
    72     nsGridLayout2::AddOffset(aState, mBoxInColumn, min);
    74     nsBoxLayout::AddLargestSize(sum, min);
    75   }
    77   if (mBoxInRow) {
    78     nsSize min = mBoxInRow->GetMinSize(aState);
    80     nsBox::AddMargin(mBoxInRow, min);
    81     nsGridLayout2::AddOffset(aState, mBoxInRow, min);
    83     nsBoxLayout::AddLargestSize(sum, min);
    84   }
    86   return sum;
    87 }
    89 nsSize
    90 nsGridCell::GetMaxSize(nsBoxLayoutState& aState)
    91 {
    92   nsSize sum(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
    94   // take our 2 children and add them up.
    95   // we are as wide as the smallest child plus its left offset
    96   // we are tall as the shortest child plus its top offset
    98   if (mBoxInColumn) {
    99     nsSize max = mBoxInColumn->GetMaxSize(aState);
   101     nsBox::AddMargin(mBoxInColumn, max);
   102     nsGridLayout2::AddOffset(aState, mBoxInColumn, max);
   104     nsBoxLayout::AddSmallestSize(sum, max);
   105   }
   107   if (mBoxInRow) {
   108     nsSize max = mBoxInRow->GetMaxSize(aState);
   110     nsBox::AddMargin(mBoxInRow, max);
   111     nsGridLayout2::AddOffset(aState, mBoxInRow, max);
   113     nsBoxLayout::AddSmallestSize(sum, max);
   114   }
   116   return sum;
   117 }
   120 bool
   121 nsGridCell::IsCollapsed()
   122 {
   123   return ((mBoxInColumn && mBoxInColumn->IsCollapsed()) ||
   124           (mBoxInRow && mBoxInRow->IsCollapsed()));
   125 }

mercurial