~ubuntu-branches/ubuntu/intrepid/xulrunner-1.9/intrepid

« back to all changes in this revision

Viewing changes to mozilla/layout/generic/nsBRFrame.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Fabien Tassin
  • Date: 2008-02-13 11:47:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080213114721-7om0mgzngvuk9czv
Tags: 1.9~b3+nobinonly-0ubuntu1
* release FIREFOX_3_0b3_RELEASE

[ Alexander Sack ]
* submit patch that ships xpcshell to bugzilla
  - rename debian/patches/ship_xpcshell.patch =>
           debian/patches/bz410617_att295212_ship_xpcshell.patch
  - update debian/patches/series
* fix tooltip in epiphany: previously displayed out of screen bounds
  (LP: #37507)
  - add debian/patches/bz233371_att297343_fix_outofscreen_embed_tooltip.patch
  - update debian/patches/series
* use default upstream gcc tweaks for improved performance - especially of the
  javascript engine
  - update debian/rules
* update global extension/plugin patch to apply cleanly against latest code
  - update debian/patches/bzXXX_gre_extension_plugin_support.patch
* fix pyxpcom build failure introduced by recent commit
  - add debian/patches/bzXXX_fix_pyxpcom_build_failure.patch
  - update debian/patches/series
* add distro independent global install locations for extensions,
  /usr/lib/mozilla/extensions and /usr/share/mozilla/extensions
  - update debian/xulrunner-1.9.dirs
* support embedded tarball layout when either there is a *.tar.bz2 in orig tarball
  or if DEBIAN_MOZCLIENT_EMBEDDED is not unset (you will need this to produce embedded
  tarballs during |get-orig-source|
  - update debian/rules
* bump minimum libnss3-dev build requirements to >= 3.12.0~1.9b3
  - update debian/control
* bump minimum libnspr4-dev build requirements to >= 4.7.0~1.9b3
  - update debian/control

[ Fabien Tassin ]
* Drop patches applied upstream
  - drop debian/patches/bz410617_att295212_ship_xpcshell.patch
  - drop debian/patches/bz404634_att294921.patch
  - drop debian/patches/bz386610_python2.5_ftbfs_amd64.patch
  - drop debian/patches/bz373918_att295042.patch
  - drop debian/patches/bz408062_unstable_pc.patch
  - drop debian/patches/bz384304_fix_recursive_symlinks.patch
  - update debian/patches/series
* Refresh diverged patches:
  - update debian/patches/bzXXX_pc_honour_system_nspr_nss.patch
  - update debian/patches/rename_venkman_addon.patch
  - update debian/patches/bz344818_cairo_xrender.patch
* Install links for all .so libs in the -dev package
  - update debian/patches/dont_install_so_in_dev.patch
* Bump gtk requirement to 2.12 as per Mozilla bug 412432
  - update debian/control
* Add #DEBHELPER# token to postinst/prerm scripts
  - update debian/xulrunner-1.9.{postinst,prerm}
* Install previously missed libdbusservice.so
  - update debian/xulrunner-1.9.install
* Update venkman patch to also rename locales
  - update debian/patches/rename_venkman_addon.patch
* Bump requirement for system cairo to >= 1.5.8 as we now need
  the newly added cairo_path_extents()
  - update debian/rules
* Include mozilla-devscripts file using -include so ifneq could be omitted
  - update debian/rules
* Fix missing .so symlinks regression
  - update debian/patches/dont_install_so_in_dev.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is mozilla.org code.
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either of the GNU General Public License Version 2 or later (the "GPL"),
26
 
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
/* rendering object for HTML <br> elements */
39
 
 
40
 
#include "nsCOMPtr.h"
41
 
#include "nsFrame.h"
42
 
#include "nsHTMLParts.h"
43
 
#include "nsPresContext.h"
44
 
#include "nsLineLayout.h"
45
 
#include "nsStyleConsts.h"
46
 
#include "nsGkAtoms.h"
47
 
#include "nsIFontMetrics.h"
48
 
#include "nsIRenderingContext.h"
49
 
#include "nsLayoutUtils.h"
50
 
 
51
 
#ifdef ACCESSIBILITY
52
 
#include "nsIServiceManager.h"
53
 
#include "nsIAccessible.h"
54
 
#include "nsIAccessibilityService.h"
55
 
#endif
56
 
 
57
 
//FOR SELECTION
58
 
#include "nsIContent.h"
59
 
#include "nsFrameSelection.h"
60
 
//END INCLUDES FOR SELECTION
61
 
 
62
 
class BRFrame : public nsFrame {
63
 
public:
64
 
  friend nsIFrame* NS_NewBRFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
65
 
 
66
 
  virtual ContentOffsets CalcContentOffsetsFromFramePoint(nsPoint aPoint);
67
 
 
68
 
  virtual PRBool PeekOffsetNoAmount(PRBool aForward, PRInt32* aOffset);
69
 
  virtual PRBool PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset);
70
 
  virtual PRBool PeekOffsetWord(PRBool aForward, PRBool aWordSelectEatSpace, PRBool aIsKeyboardSelect,
71
 
                                PRInt32* aOffset, PeekWordState* aState);
72
 
 
73
 
  NS_IMETHOD Reflow(nsPresContext* aPresContext,
74
 
                    nsHTMLReflowMetrics& aDesiredSize,
75
 
                    const nsHTMLReflowState& aReflowState,
76
 
                    nsReflowStatus& aStatus);
77
 
  virtual void AddInlineMinWidth(nsIRenderingContext *aRenderingContext,
78
 
                                 InlineMinWidthData *aData);
79
 
  virtual void AddInlinePrefWidth(nsIRenderingContext *aRenderingContext,
80
 
                                  InlinePrefWidthData *aData);
81
 
  virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
82
 
  virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
83
 
  virtual nsIAtom* GetType() const;
84
 
 
85
 
  virtual PRBool IsFrameOfType(PRUint32 aFlags) const
86
 
  {
87
 
    return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced |
88
 
                                             nsIFrame::eLineParticipant));
89
 
  }
90
 
 
91
 
#ifdef ACCESSIBILITY  
92
 
  NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
93
 
#endif
94
 
 
95
 
protected:
96
 
  BRFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
97
 
  virtual ~BRFrame();
98
 
};
99
 
 
100
 
nsIFrame*
101
 
NS_NewBRFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
102
 
{
103
 
  return new (aPresShell) BRFrame(aContext);
104
 
}
105
 
 
106
 
BRFrame::~BRFrame()
107
 
{
108
 
}
109
 
 
110
 
NS_IMETHODIMP
111
 
BRFrame::Reflow(nsPresContext* aPresContext,
112
 
                nsHTMLReflowMetrics& aMetrics,
113
 
                const nsHTMLReflowState& aReflowState,
114
 
                nsReflowStatus& aStatus)
115
 
{
116
 
  DO_GLOBAL_REFLOW_COUNT("BRFrame");
117
 
  DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
118
 
  aMetrics.height = 0; // BR frames with height 0 are ignored in quirks
119
 
                       // mode by nsLineLayout::VerticalAlignFrames .
120
 
                       // However, it's not always 0.  See below.
121
 
  aMetrics.width = 0;
122
 
  aMetrics.ascent = 0;
123
 
 
124
 
  // Only when the BR is operating in a line-layout situation will it
125
 
  // behave like a BR.
126
 
  nsLineLayout* ll = aReflowState.mLineLayout;
127
 
  if (ll) {
128
 
    // Note that the compatibility mode check excludes AlmostStandards
129
 
    // mode, since this is the inline box model.  See bug 161691.
130
 
    if ( ll->CanPlaceFloatNow() ||
131
 
         aPresContext->CompatibilityMode() == eCompatibility_FullStandards ) {
132
 
      // If we can place a float on the line now it means that the
133
 
      // line is effectively empty (there may be zero sized compressed
134
 
      // white-space frames on the line, but they are to be ignored).
135
 
      //
136
 
      // If this frame is going to terminate the line we know
137
 
      // that nothing else will go on the line. Therefore, in this
138
 
      // case, we provide some height for the BR frame so that it
139
 
      // creates some vertical whitespace.  It's necessary to use the
140
 
      // line-height rather than the font size because the
141
 
      // quirks-mode fix that doesn't apply the block's min
142
 
      // line-height makes this necessary to make BR cause a line
143
 
      // of the full line-height
144
 
 
145
 
      // We also do this in strict mode because BR should act like a
146
 
      // normal inline frame.  That line-height is used is important
147
 
      // here for cases where the line-height is less that 1.
148
 
      nsLayoutUtils::SetFontFromStyle(aReflowState.rendContext, mStyleContext);
149
 
      nsCOMPtr<nsIFontMetrics> fm;
150
 
      aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm));
151
 
      if (fm) {
152
 
        nscoord ascent, descent;
153
 
        fm->GetMaxAscent(ascent);
154
 
        fm->GetMaxDescent(descent);
155
 
        nscoord logicalHeight =
156
 
          aReflowState.CalcLineHeight(aReflowState.rendContext, this);
157
 
        nscoord leading = logicalHeight - ascent - descent;
158
 
        aMetrics.height = logicalHeight;
159
 
        aMetrics.ascent = ascent + (leading/2);
160
 
      }
161
 
      else {
162
 
        aMetrics.ascent = aMetrics.height = 0;
163
 
      }
164
 
 
165
 
      // XXX temporary until I figure out a better solution; see the
166
 
      // code in nsLineLayout::VerticalAlignFrames that zaps minY/maxY
167
 
      // if the width is zero.
168
 
      // XXX This also fixes bug 10036!
169
 
      // Warning: nsTextControlFrame::CalculateSizeStandard depends on
170
 
      // the following line, see bug 228752.
171
 
      aMetrics.width = 1;
172
 
    }
173
 
 
174
 
    // Return our reflow status
175
 
    PRUint32 breakType = aReflowState.mStyleDisplay->mBreakType;
176
 
    if (NS_STYLE_CLEAR_NONE == breakType) {
177
 
      breakType = NS_STYLE_CLEAR_LINE;
178
 
    }
179
 
 
180
 
    aStatus = NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
181
 
      NS_INLINE_MAKE_BREAK_TYPE(breakType);
182
 
    ll->SetLineEndsInBR(PR_TRUE);
183
 
  }
184
 
  else {
185
 
    aStatus = NS_FRAME_COMPLETE;
186
 
  }
187
 
  
188
 
  aMetrics.mOverflowArea = nsRect(0, 0, aMetrics.width, aMetrics.height);
189
 
 
190
 
  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
191
 
  return NS_OK;
192
 
}
193
 
 
194
 
/* virtual */ void
195
 
BRFrame::AddInlineMinWidth(nsIRenderingContext *aRenderingContext,
196
 
                           nsIFrame::InlineMinWidthData *aData)
197
 
{
198
 
  aData->ForceBreak(aRenderingContext);
199
 
}
200
 
 
201
 
/* virtual */ void
202
 
BRFrame::AddInlinePrefWidth(nsIRenderingContext *aRenderingContext,
203
 
                            nsIFrame::InlinePrefWidthData *aData)
204
 
{
205
 
  aData->ForceBreak(aRenderingContext);
206
 
}
207
 
 
208
 
/* virtual */ nscoord
209
 
BRFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
210
 
{
211
 
  nscoord result = 0;
212
 
  DISPLAY_MIN_WIDTH(this, result);
213
 
  return result;
214
 
}
215
 
 
216
 
/* virtual */ nscoord
217
 
BRFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
218
 
{
219
 
  nscoord result = 0;
220
 
  DISPLAY_PREF_WIDTH(this, result);
221
 
  return result;
222
 
}
223
 
 
224
 
nsIAtom*
225
 
BRFrame::GetType() const
226
 
{
227
 
  return nsGkAtoms::brFrame;
228
 
}
229
 
 
230
 
nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoint)
231
 
{
232
 
  ContentOffsets offsets;
233
 
  offsets.content = mContent->GetParent();
234
 
  if (offsets.content) {
235
 
    offsets.offset = offsets.content->IndexOf(mContent);
236
 
    offsets.secondaryOffset = offsets.offset;
237
 
    offsets.associateWithNext = PR_TRUE;
238
 
  }
239
 
  return offsets;
240
 
}
241
 
 
242
 
PRBool
243
 
BRFrame::PeekOffsetNoAmount(PRBool aForward, PRInt32* aOffset)
244
 
{
245
 
  NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
246
 
  PRInt32 startOffset = *aOffset;
247
 
  // If we hit the end of a BR going backwards, go to its beginning and stay there.
248
 
  if (!aForward && startOffset != 0) {
249
 
    *aOffset = 0;
250
 
    return PR_TRUE;
251
 
  }
252
 
  // Otherwise, stop if we hit the beginning, continue (forward) if we hit the end.
253
 
  return (startOffset == 0);
254
 
}
255
 
 
256
 
PRBool
257
 
BRFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
258
 
{
259
 
  NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
260
 
  // Keep going. The actual line jumping will stop us.
261
 
  return PR_FALSE;
262
 
}
263
 
 
264
 
PRBool
265
 
BRFrame::PeekOffsetWord(PRBool aForward, PRBool aWordSelectEatSpace, PRBool aIsKeyboardSelect,
266
 
                        PRInt32* aOffset, PeekWordState* aState)
267
 
{
268
 
  NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
269
 
  // Keep going. The actual line jumping will stop us.
270
 
  return PR_FALSE;
271
 
}
272
 
 
273
 
#ifdef ACCESSIBILITY
274
 
NS_IMETHODIMP BRFrame::GetAccessible(nsIAccessible** aAccessible)
275
 
{
276
 
  nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
277
 
  if (accService) {
278
 
    return accService->CreateHTMLBRAccessible(static_cast<nsIFrame*>(this), aAccessible);
279
 
  }
280
 
  return NS_ERROR_FAILURE;
281
 
}
282
 
#endif
283