Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsFrameSetFrame.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/* rendering object for HTML <frameset> elements */
8
9
#include "nsFrameSetFrame.h"
10
11
#include "gfxContext.h"
12
#include "gfxUtils.h"
13
#include "mozilla/ComputedStyle.h"
14
#include "mozilla/DebugOnly.h"
15
#include "mozilla/gfx/2D.h"
16
#include "mozilla/gfx/Helpers.h"
17
#include "mozilla/Likely.h"
18
19
#include "nsGenericHTMLElement.h"
20
#include "nsAttrValueInlines.h"
21
#include "nsLeafFrame.h"
22
#include "nsContainerFrame.h"
23
#include "nsLayoutUtils.h"
24
#include "nsPresContext.h"
25
#include "nsIContentInlines.h"
26
#include "nsIPresShell.h"
27
#include "nsGkAtoms.h"
28
#include "nsStyleConsts.h"
29
#include "nsHTMLParts.h"
30
#include "nsNameSpaceManager.h"
31
#include "nsCSSAnonBoxes.h"
32
#include "mozilla/ServoStyleSet.h"
33
#include "mozilla/dom/Element.h"
34
#include "nsDisplayList.h"
35
#include "nsNodeUtils.h"
36
#include "mozAutoDocUpdate.h"
37
#include "mozilla/Preferences.h"
38
#include "mozilla/dom/HTMLFrameSetElement.h"
39
#include "mozilla/LookAndFeel.h"
40
#include "mozilla/MouseEvents.h"
41
#include "nsSubDocumentFrame.h"
42
43
using namespace mozilla;
44
using namespace mozilla::dom;
45
using namespace mozilla::gfx;
46
47
// masks for mEdgeVisibility
48
0
#define LEFT_VIS   0x0001
49
0
#define RIGHT_VIS  0x0002
50
0
#define TOP_VIS    0x0004
51
0
#define BOTTOM_VIS 0x0008
52
0
#define ALL_VIS    0x000F
53
0
#define NONE_VIS   0x0000
54
55
/*******************************************************************************
56
 * nsFramesetDrag
57
 ******************************************************************************/
58
nsFramesetDrag::nsFramesetDrag()
59
0
{
60
0
  UnSet();
61
0
}
62
63
void nsFramesetDrag::Reset(bool                 aVertical,
64
                           int32_t              aIndex,
65
                           int32_t              aChange,
66
                           nsHTMLFramesetFrame* aSource)
67
0
{
68
0
  mVertical = aVertical;
69
0
  mIndex    = aIndex;
70
0
  mChange   = aChange;
71
0
  mSource   = aSource;
72
0
}
73
74
void nsFramesetDrag::UnSet()
75
0
{
76
0
  mVertical = true;
77
0
  mIndex    = -1;
78
0
  mChange   = 0;
79
0
  mSource   = nullptr;
80
0
}
81
82
/*******************************************************************************
83
 * nsHTMLFramesetBorderFrame
84
 ******************************************************************************/
85
class nsHTMLFramesetBorderFrame final : public nsLeafFrame
86
{
87
public:
88
  NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetBorderFrame)
89
90
#ifdef DEBUG_FRAME_DUMP
91
  virtual nsresult GetFrameName(nsAString& aResult) const override;
92
#endif
93
94
  virtual nsresult HandleEvent(nsPresContext* aPresContext,
95
                               WidgetGUIEvent* aEvent,
96
                               nsEventStatus* aEventStatus) override;
97
98
  virtual nsresult GetCursor(const nsPoint&    aPoint,
99
                             nsIFrame::Cursor& aCursor) override;
100
101
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
102
                                const nsDisplayListSet& aLists) override;
103
104
  virtual void Reflow(nsPresContext*           aPresContext,
105
                          ReflowOutput&     aDesiredSize,
106
                          const ReflowInput& aReflowInput,
107
                          nsReflowStatus&          aStatus) override;
108
109
0
  bool GetVisibility() { return mVisibility; }
110
  void SetVisibility(bool aVisibility);
111
  void SetColor(nscolor aColor);
112
113
  void PaintBorder(DrawTarget* aDrawTarget, nsPoint aPt);
114
115
protected:
116
  nsHTMLFramesetBorderFrame(ComputedStyle* aStyle, int32_t aWidth, bool aVertical, bool aVisible);
117
  virtual ~nsHTMLFramesetBorderFrame();
118
  virtual nscoord GetIntrinsicISize() override;
119
  virtual nscoord GetIntrinsicBSize() override;
120
121
  // the prev and next neighbors are indexes into the row (for a horizontal border) or col (for
122
  // a vertical border) of nsHTMLFramesetFrames or nsHTMLFrames
123
  int32_t mPrevNeighbor;
124
  int32_t mNextNeighbor;
125
  nscolor mColor;
126
  int32_t mWidth;
127
  bool mVertical;
128
  bool mVisibility;
129
  bool mCanResize;
130
  friend class nsHTMLFramesetFrame;
131
};
132
/*******************************************************************************
133
 * nsHTMLFramesetBlankFrame
134
 ******************************************************************************/
135
class nsHTMLFramesetBlankFrame final : public nsLeafFrame
136
{
137
public:
138
  NS_DECL_QUERYFRAME
139
  NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetBlankFrame)
140
141
#ifdef DEBUG_FRAME_DUMP
142
  virtual nsresult GetFrameName(nsAString& aResult) const override
143
  {
144
    return MakeFrameName(NS_LITERAL_STRING("FramesetBlank"), aResult);
145
  }
146
#endif
147
148
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
149
                                const nsDisplayListSet& aLists) override;
150
151
  virtual void Reflow(nsPresContext*           aPresContext,
152
                          ReflowOutput&     aDesiredSize,
153
                          const ReflowInput& aReflowInput,
154
                          nsReflowStatus&          aStatus) override;
155
156
protected:
157
  explicit nsHTMLFramesetBlankFrame(ComputedStyle* aStyle)
158
    : nsLeafFrame(aStyle, kClassID)
159
0
  {}
160
161
  virtual ~nsHTMLFramesetBlankFrame();
162
  virtual nscoord GetIntrinsicISize() override;
163
  virtual nscoord GetIntrinsicBSize() override;
164
165
  friend class nsHTMLFramesetFrame;
166
  friend class nsHTMLFrameset;
167
};
168
169
/*******************************************************************************
170
 * nsHTMLFramesetFrame
171
 ******************************************************************************/
172
bool    nsHTMLFramesetFrame::gDragInProgress = false;
173
0
#define DEFAULT_BORDER_WIDTH_PX 6
174
175
nsHTMLFramesetFrame::nsHTMLFramesetFrame(ComputedStyle* aStyle)
176
  : nsContainerFrame(aStyle, kClassID)
177
0
{
178
0
  mNumRows             = 0;
179
0
  mNumCols             = 0;
180
0
  mEdgeVisibility      = 0;
181
0
  mParentFrameborder   = eFrameborder_Yes; // default
182
0
  mParentBorderWidth   = -1; // default not set
183
0
  mParentBorderColor   = NO_COLOR; // default not set
184
0
  mFirstDragPoint.x     = mFirstDragPoint.y = 0;
185
0
  mMinDrag             = nsPresContext::CSSPixelsToAppUnits(2);
186
0
  mNonBorderChildCount = 0;
187
0
  mNonBlankChildCount  = 0;
188
0
  mDragger             = nullptr;
189
0
  mChildCount          = 0;
190
0
  mTopLevelFrameset    = nullptr;
191
0
  mEdgeColors.Set(NO_COLOR);
192
0
}
193
194
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
195
0
{
196
0
}
197
198
0
NS_QUERYFRAME_HEAD(nsHTMLFramesetFrame)
199
0
  NS_QUERYFRAME_ENTRY(nsHTMLFramesetFrame)
200
0
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
201
202
void
203
nsHTMLFramesetFrame::Init(nsIContent*       aContent,
204
                          nsContainerFrame* aParent,
205
                          nsIFrame*         aPrevInFlow)
206
0
{
207
0
  nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
208
0
  // find the highest ancestor that is a frameset
209
0
  nsIFrame* parentFrame = GetParent();
210
0
  mTopLevelFrameset = this;
211
0
  while (parentFrame) {
212
0
    nsHTMLFramesetFrame* frameset = do_QueryFrame(parentFrame);
213
0
    if (frameset) {
214
0
      mTopLevelFrameset = frameset;
215
0
      parentFrame = parentFrame->GetParent();
216
0
    } else {
217
0
      break;
218
0
    }
219
0
  }
220
0
221
0
  nsPresContext* presContext = PresContext();
222
0
  nsIPresShell* shell = presContext->PresShell();
223
0
224
0
  nsFrameborder  frameborder = GetFrameBorder();
225
0
  int32_t borderWidth = GetBorderWidth(presContext, false);
226
0
  nscolor borderColor = GetBorderColor();
227
0
228
0
  // Get the rows= cols= data
229
0
  HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
230
0
  NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
231
0
  const nsFramesetSpec* rowSpecs = nullptr;
232
0
  const nsFramesetSpec* colSpecs = nullptr;
233
0
  // GetRowSpec and GetColSpec can fail, but when they do they set
234
0
  // mNumRows and mNumCols respectively to 0, so we deal with it fine.
235
0
  ourContent->GetRowSpec(&mNumRows, &rowSpecs);
236
0
  ourContent->GetColSpec(&mNumCols, &colSpecs);
237
0
238
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscoord),
239
0
                "Maximum value of mNumRows and mNumCols is NS_MAX_FRAMESET_SPEC_COUNT");
240
0
  mRowSizes  = MakeUnique<nscoord[]>(mNumRows);
241
0
  mColSizes  = MakeUnique<nscoord[]>(mNumCols);
242
0
243
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT,
244
0
                "Should not overflow numCells");
245
0
  int32_t numCells = mNumRows*mNumCols;
246
0
247
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nsHTMLFramesetBorderFrame*),
248
0
                "Should not overflow nsHTMLFramesetBorderFrame");
249
0
  mVerBorders    = MakeUnique<nsHTMLFramesetBorderFrame*[]>(mNumCols);  // 1 more than number of ver borders
250
0
251
0
  for (int verX  = 0; verX < mNumCols; verX++)
252
0
    mVerBorders[verX]    = nullptr;
253
0
254
0
  mHorBorders    = MakeUnique<nsHTMLFramesetBorderFrame*[]>(mNumRows);  // 1 more than number of hor borders
255
0
256
0
  for (int horX = 0; horX < mNumRows; horX++)
257
0
    mHorBorders[horX]    = nullptr;
258
0
259
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT
260
0
                   < UINT_MAX / sizeof(int32_t) / NS_MAX_FRAMESET_SPEC_COUNT,
261
0
                "Should not overflow numCells");
262
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT
263
0
                   < UINT_MAX / sizeof(nsFrameborder) / NS_MAX_FRAMESET_SPEC_COUNT,
264
0
                "Should not overflow numCells");
265
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT
266
0
                   < UINT_MAX / sizeof(nsBorderColor) / NS_MAX_FRAMESET_SPEC_COUNT,
267
0
                "Should not overflow numCells");
268
0
  mChildFrameborder  = MakeUnique<nsFrameborder[]>(numCells);
269
0
  mChildBorderColors  = MakeUnique<nsBorderColor[]>(numCells);
270
0
271
0
  // create the children frames; skip content which isn't <frameset> or <frame>
272
0
  mChildCount = 0; // number of <frame> or <frameset> children
273
0
274
0
  for (nsIContent* child = mContent->GetFirstChild();
275
0
       child;
276
0
       child = child->GetNextSibling()) {
277
0
    if (mChildCount == numCells) { // we have more <frame> or <frameset> than cells
278
0
      // Clear the lazy bits in the remaining children.  Also clear
279
0
      // the restyle flags, like nsCSSFrameConstructor::ProcessChildren does.
280
0
      for (; child; child = child->GetNextSibling()) {
281
0
        child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
282
0
      }
283
0
      break;
284
0
    }
285
0
    child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
286
0
287
0
    // IMPORTANT: This must match the conditions in
288
0
    // nsCSSFrameConstructor::ContentAppended/Inserted/Removed
289
0
    if (!child->IsHTMLElement()) {
290
0
      continue;
291
0
    }
292
0
293
0
    if (!child->IsAnyOfHTMLElements(nsGkAtoms::frameset, nsGkAtoms::frame)) {
294
0
      continue;
295
0
    }
296
0
297
0
    RefPtr<ComputedStyle> kidSC =
298
0
      shell->StyleSet()->ResolveStyleFor(child->AsElement(),
299
0
                                         LazyComputeBehavior::Allow);
300
0
301
0
    nsIFrame* frame;
302
0
    if (child->IsHTMLElement(nsGkAtoms::frameset)) {
303
0
      frame = NS_NewHTMLFramesetFrame(shell, kidSC);
304
0
305
0
      nsHTMLFramesetFrame* childFrame = (nsHTMLFramesetFrame*)frame;
306
0
      childFrame->SetParentFrameborder(frameborder);
307
0
      childFrame->SetParentBorderWidth(borderWidth);
308
0
      childFrame->SetParentBorderColor(borderColor);
309
0
      frame->Init(child, this, nullptr);
310
0
311
0
      mChildBorderColors[mChildCount].Set(childFrame->GetBorderColor());
312
0
    } else { // frame
313
0
      frame = NS_NewSubDocumentFrame(shell, kidSC);
314
0
315
0
      frame->Init(child, this, nullptr);
316
0
317
0
      mChildFrameborder[mChildCount] = GetFrameBorder(child);
318
0
      mChildBorderColors[mChildCount].Set(GetBorderColor(child));
319
0
    }
320
0
    child->SetPrimaryFrame(frame);
321
0
322
0
    mFrames.AppendFrame(nullptr, frame);
323
0
324
0
    mChildCount++;
325
0
  }
326
0
327
0
  mNonBlankChildCount = mChildCount;
328
0
  // add blank frames for frameset cells that had no content provided
329
0
  for (int blankX = mChildCount; blankX < numCells; blankX++) {
330
0
    RefPtr<ComputedStyle> pseudoComputedStyle;
331
0
    pseudoComputedStyle = shell->StyleSet()->
332
0
      ResolveNonInheritingAnonymousBoxStyle(nsCSSAnonBoxes::framesetBlank());
333
0
334
0
    // XXX the blank frame is using the content of its parent - at some point it
335
0
    // should just have null content, if we support that
336
0
    nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame(pseudoComputedStyle);
337
0
338
0
    blankFrame->Init(mContent, this, nullptr);
339
0
340
0
    mFrames.AppendFrame(nullptr, blankFrame);
341
0
342
0
    mChildBorderColors[mChildCount].Set(NO_COLOR);
343
0
    mChildCount++;
344
0
  }
345
0
346
0
  mNonBorderChildCount = mChildCount;
347
0
}
348
349
void
350
nsHTMLFramesetFrame::SetInitialChildList(ChildListID  aListID,
351
                                         nsFrameList& aChildList)
352
0
{
353
0
  // We do this weirdness where we create our child frames in Init().  On the
354
0
  // other hand, we're going to get a SetInitialChildList() with an empty list
355
0
  // and null list name after the frame constructor is done creating us.  So
356
0
  // just ignore that call.
357
0
  if (aListID == kPrincipalList && aChildList.IsEmpty()) {
358
0
    return;
359
0
  }
360
0
361
0
  nsContainerFrame::SetInitialChildList(aListID, aChildList);
362
0
}
363
364
// XXX should this try to allocate twips based on an even pixel boundary?
365
void nsHTMLFramesetFrame::Scale(nscoord  aDesired,
366
                                int32_t  aNumIndicies,
367
                                int32_t* aIndicies,
368
                                int32_t  aNumItems,
369
                                int32_t* aItems)
370
0
{
371
0
  int32_t actual = 0;
372
0
  int32_t i, j;
373
0
  // get the actual total
374
0
  for (i = 0; i < aNumIndicies; i++) {
375
0
    j = aIndicies[i];
376
0
    actual += aItems[j];
377
0
  }
378
0
379
0
  if (actual > 0) {
380
0
    float factor = (float)aDesired / (float)actual;
381
0
    actual = 0;
382
0
    // scale the items up or down
383
0
    for (i = 0; i < aNumIndicies; i++) {
384
0
      j = aIndicies[i];
385
0
      aItems[j] = NSToCoordRound((float)aItems[j] * factor);
386
0
      actual += aItems[j];
387
0
    }
388
0
  } else if (aNumIndicies != 0) {
389
0
    // All the specs say zero width, but we have to fill up space
390
0
    // somehow.  Distribute it equally.
391
0
    nscoord width = NSToCoordRound((float)aDesired / (float)aNumIndicies);
392
0
    actual = width * aNumIndicies;
393
0
    for (i = 0; i < aNumIndicies; i++) {
394
0
      aItems[aIndicies[i]] = width;
395
0
    }
396
0
  }
397
0
398
0
  if (aNumIndicies > 0 && aDesired != actual) {
399
0
    int32_t unit = (aDesired > actual) ? 1 : -1;
400
0
    for (i=0; (i < aNumIndicies) && (aDesired != actual); i++) {
401
0
      j = aIndicies[i];
402
0
      if (j < aNumItems) {
403
0
        aItems[j] += unit;
404
0
        actual += unit;
405
0
      }
406
0
    }
407
0
  }
408
0
}
409
410
411
/**
412
  * Translate the rows/cols specs into an array of integer sizes for
413
  * each cell in the frameset. Sizes are allocated based on the priorities of the
414
  * specifier - fixed sizes have the highest priority, percentage sizes have the next
415
  * highest priority and relative sizes have the lowest.
416
  */
417
void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext*        aPresContext,
418
                                          nscoord               aSize,
419
                                          int32_t               aNumSpecs,
420
                                          const nsFramesetSpec* aSpecs,
421
                                          nscoord*              aValues)
422
0
{
423
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(int32_t),
424
0
                "aNumSpecs maximum value is NS_MAX_FRAMESET_SPEC_COUNT");
425
0
426
0
  int32_t  fixedTotal = 0;
427
0
  int32_t  numFixed = 0;
428
0
  auto fixed = MakeUnique<int32_t[]>(aNumSpecs);
429
0
  int32_t  numPercent = 0;
430
0
  auto percent = MakeUnique<int32_t[]>(aNumSpecs);
431
0
  int32_t  relativeSums = 0;
432
0
  int32_t  numRelative = 0;
433
0
  auto relative = MakeUnique<int32_t[]>(aNumSpecs);
434
0
435
0
  if (MOZ_UNLIKELY(!fixed || !percent || !relative)) {
436
0
    return; // NS_ERROR_OUT_OF_MEMORY
437
0
  }
438
0
439
0
  int32_t i, j;
440
0
441
0
  // initialize the fixed, percent, relative indices, allocate the fixed sizes and zero the others
442
0
  for (i = 0; i < aNumSpecs; i++) {
443
0
    aValues[i] = 0;
444
0
    switch (aSpecs[i].mUnit) {
445
0
      case eFramesetUnit_Fixed:
446
0
        aValues[i] = nsPresContext::CSSPixelsToAppUnits(aSpecs[i].mValue);
447
0
        fixedTotal += aValues[i];
448
0
        fixed[numFixed] = i;
449
0
        numFixed++;
450
0
        break;
451
0
      case eFramesetUnit_Percent:
452
0
        percent[numPercent] = i;
453
0
        numPercent++;
454
0
        break;
455
0
      case eFramesetUnit_Relative:
456
0
        relative[numRelative] = i;
457
0
        numRelative++;
458
0
        relativeSums += aSpecs[i].mValue;
459
0
        break;
460
0
    }
461
0
  }
462
0
463
0
  // scale the fixed sizes if they total too much (or too little and there aren't any percent or relative)
464
0
  if ((fixedTotal > aSize) || ((fixedTotal < aSize) && (0 == numPercent) && (0 == numRelative))) {
465
0
    Scale(aSize, numFixed, fixed.get(), aNumSpecs, aValues);
466
0
    return;
467
0
  }
468
0
469
0
  int32_t percentMax = aSize - fixedTotal;
470
0
  int32_t percentTotal = 0;
471
0
  // allocate the percentage sizes from what is left over from the fixed allocation
472
0
  for (i = 0; i < numPercent; i++) {
473
0
    j = percent[i];
474
0
    aValues[j] = NSToCoordRound((float)aSpecs[j].mValue * (float)aSize / 100.0f);
475
0
    percentTotal += aValues[j];
476
0
  }
477
0
478
0
  // scale the percent sizes if they total too much (or too little and there aren't any relative)
479
0
  if ((percentTotal > percentMax) || ((percentTotal < percentMax) && (0 == numRelative))) {
480
0
    Scale(percentMax, numPercent, percent.get(), aNumSpecs, aValues);
481
0
    return;
482
0
  }
483
0
484
0
  int32_t relativeMax = percentMax - percentTotal;
485
0
  int32_t relativeTotal = 0;
486
0
  // allocate the relative sizes from what is left over from the percent allocation
487
0
  for (i = 0; i < numRelative; i++) {
488
0
    j = relative[i];
489
0
    aValues[j] = NSToCoordRound((float)aSpecs[j].mValue * (float)relativeMax / (float)relativeSums);
490
0
    relativeTotal += aValues[j];
491
0
  }
492
0
493
0
  // scale the relative sizes if they take up too much or too little
494
0
  if (relativeTotal != relativeMax) {
495
0
    Scale(relativeMax, numRelative, relative.get(), aNumSpecs, aValues);
496
0
  }
497
0
}
498
499
500
/**
501
  * Translate the rows/cols integer sizes into an array of specs for
502
  * each cell in the frameset.  Reverse of CalculateRowCol() behaviour.
503
  * This allows us to maintain the user size info through reflows.
504
  */
505
void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext*        aPresContext,
506
                                         nscoord               aSize,
507
                                         int32_t               aNumSpecs,
508
                                         const nsFramesetSpec* aSpecs,
509
                                         nscoord*              aValues,
510
                                         nsString&             aNewAttr)
511
0
{
512
0
  int32_t i;
513
0
514
0
  for (i = 0; i < aNumSpecs; i++) {
515
0
    if (!aNewAttr.IsEmpty())
516
0
      aNewAttr.Append(char16_t(','));
517
0
518
0
    switch (aSpecs[i].mUnit) {
519
0
      case eFramesetUnit_Fixed:
520
0
        aNewAttr.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(aValues[i]));
521
0
        break;
522
0
      case eFramesetUnit_Percent: // XXX Only accurate to 1%, need 1 pixel
523
0
      case eFramesetUnit_Relative:
524
0
        // Add 0.5 to the percentage to make rounding work right.
525
0
        aNewAttr.AppendInt(uint32_t((100.0*aValues[i])/aSize + 0.5));
526
0
        aNewAttr.Append(char16_t('%'));
527
0
        break;
528
0
    }
529
0
  }
530
0
}
531
532
int32_t nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
533
                                            bool aTakeForcingIntoAccount)
534
0
{
535
0
  nsFrameborder frameborder = GetFrameBorder();
536
0
  if (frameborder == eFrameborder_No) {
537
0
    return 0;
538
0
  }
539
0
  nsGenericHTMLElement *content = nsGenericHTMLElement::FromNode(mContent);
540
0
541
0
  if (content) {
542
0
    const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::border);
543
0
    if (attr) {
544
0
      int32_t intVal = 0;
545
0
      if (attr->Type() == nsAttrValue::eInteger) {
546
0
        intVal = attr->GetIntegerValue();
547
0
        if (intVal < 0) {
548
0
          intVal = 0;
549
0
        }
550
0
      }
551
0
552
0
      return nsPresContext::CSSPixelsToAppUnits(intVal);
553
0
    }
554
0
  }
555
0
556
0
  if (mParentBorderWidth >= 0) {
557
0
    return mParentBorderWidth;
558
0
  }
559
0
560
0
  return nsPresContext::CSSPixelsToAppUnits(DEFAULT_BORDER_WIDTH_PX);
561
0
}
562
563
void
564
nsHTMLFramesetFrame::GetDesiredSize(nsPresContext*           aPresContext,
565
                                    const ReflowInput& aReflowInput,
566
                                    ReflowOutput&     aDesiredSize)
567
0
{
568
0
  WritingMode wm = aReflowInput.GetWritingMode();
569
0
  LogicalSize desiredSize(wm);
570
0
  nsHTMLFramesetFrame* framesetParent = do_QueryFrame(GetParent());
571
0
  if (nullptr == framesetParent) {
572
0
    if (aPresContext->IsPaginated()) {
573
0
      // XXX This needs to be changed when framesets paginate properly
574
0
      desiredSize.ISize(wm) = aReflowInput.AvailableISize();
575
0
      desiredSize.BSize(wm) = aReflowInput.AvailableBSize();
576
0
    } else {
577
0
      LogicalSize area(wm, aPresContext->GetVisibleArea().Size());
578
0
579
0
      desiredSize.ISize(wm) = area.ISize(wm);
580
0
      desiredSize.BSize(wm) = area.BSize(wm);
581
0
    }
582
0
  } else {
583
0
    LogicalSize size(wm);
584
0
    framesetParent->GetSizeOfChild(this, wm, size);
585
0
    desiredSize.ISize(wm) = size.ISize(wm);
586
0
    desiredSize.BSize(wm) = size.BSize(wm);
587
0
  }
588
0
  aDesiredSize.SetSize(wm, desiredSize);
589
0
}
590
591
// only valid for non border children
592
void nsHTMLFramesetFrame::GetSizeOfChildAt(int32_t  aIndexInParent,
593
                                           WritingMode aWM,
594
                                           LogicalSize&  aSize,
595
                                           nsIntPoint& aCellIndex)
596
0
{
597
0
  int32_t row = aIndexInParent / mNumCols;
598
0
  int32_t col = aIndexInParent - (row * mNumCols); // remainder from dividing index by mNumCols
599
0
  if ((row < mNumRows) && (col < mNumCols)) {
600
0
    aSize.ISize(aWM) = mColSizes[col];
601
0
    aSize.BSize(aWM) = mRowSizes[row];
602
0
    aCellIndex.x = col;
603
0
    aCellIndex.y = row;
604
0
  } else {
605
0
    aSize.SizeTo(aWM, 0, 0);
606
0
    aCellIndex.x = aCellIndex.y = 0;
607
0
  }
608
0
}
609
610
// only valid for non border children
611
void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild,
612
                                         WritingMode aWM,
613
                                         LogicalSize& aSize)
614
0
{
615
0
  // Reflow only creates children frames for <frameset> and <frame> content.
616
0
  // this assumption is used here
617
0
  int i = 0;
618
0
  for (nsIFrame* child : mFrames) {
619
0
    if (aChild == child) {
620
0
      nsIntPoint ignore;
621
0
      GetSizeOfChildAt(i, aWM, aSize, ignore);
622
0
      return;
623
0
    }
624
0
    i++;
625
0
  }
626
0
  aSize.SizeTo(aWM, 0, 0);
627
0
}
628
629
630
nsresult nsHTMLFramesetFrame::HandleEvent(nsPresContext* aPresContext,
631
                                           WidgetGUIEvent* aEvent,
632
                                           nsEventStatus* aEventStatus)
633
0
{
634
0
  NS_ENSURE_ARG_POINTER(aEventStatus);
635
0
  if (mDragger) {
636
0
    // the nsFramesetBorderFrame has captured NS_MOUSE_DOWN
637
0
    switch (aEvent->mMessage) {
638
0
      case eMouseMove:
639
0
        MouseDrag(aPresContext, aEvent);
640
0
        break;
641
0
      case eMouseUp:
642
0
        if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
643
0
          EndMouseDrag(aPresContext);
644
0
        }
645
0
        break;
646
0
      default:
647
0
        break;
648
0
    }
649
0
    *aEventStatus = nsEventStatus_eConsumeNoDefault;
650
0
  } else {
651
0
    *aEventStatus = nsEventStatus_eIgnore;
652
0
  }
653
0
  return NS_OK;
654
0
}
655
656
nsresult
657
nsHTMLFramesetFrame::GetCursor(const nsPoint&    aPoint,
658
                               nsIFrame::Cursor& aCursor)
659
0
{
660
0
  aCursor.mLoading = false;
661
0
  if (mDragger) {
662
0
    aCursor.mCursor = (mDragger->mVertical) ? NS_STYLE_CURSOR_EW_RESIZE : NS_STYLE_CURSOR_NS_RESIZE;
663
0
  } else {
664
0
    aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
665
0
  }
666
0
  return NS_OK;
667
0
}
668
669
void
670
nsHTMLFramesetFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
671
                                      const nsDisplayListSet& aLists)
672
0
{
673
0
  BuildDisplayListForInline(aBuilder, aLists);
674
0
675
0
  if (mDragger && aBuilder->IsForEventDelivery()) {
676
0
    aLists.Content()->AppendToTop(
677
0
      MakeDisplayItem<nsDisplayEventReceiver>(aBuilder, this));
678
0
  }
679
0
}
680
681
void
682
nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame*                aChild,
683
                                      nsPresContext*           aPresContext,
684
                                      const ReflowInput& aReflowInput,
685
                                      nsPoint&                 aOffset,
686
                                      nsSize&                  aSize,
687
                                      nsIntPoint*              aCellIndex)
688
0
{
689
0
  // reflow the child
690
0
  ReflowInput reflowInput(aPresContext, aReflowInput, aChild,
691
0
                                LogicalSize(aChild->GetWritingMode(), aSize));
692
0
  reflowInput.SetComputedWidth(std::max(0, aSize.width - reflowInput.ComputedPhysicalBorderPadding().LeftRight()));
693
0
  reflowInput.SetComputedHeight(std::max(0, aSize.height - reflowInput.ComputedPhysicalBorderPadding().TopBottom()));
694
0
  ReflowOutput reflowOutput(aReflowInput);
695
0
  reflowOutput.Width() = aSize.width;
696
0
  reflowOutput.Height() = aSize.height;
697
0
  nsReflowStatus status;
698
0
699
0
  ReflowChild(aChild, aPresContext, reflowOutput, reflowInput, aOffset.x,
700
0
              aOffset.y, 0, status);
701
0
  NS_ASSERTION(status.IsComplete(), "bad status");
702
0
703
0
  // Place and size the child
704
0
  reflowOutput.Width() = aSize.width;
705
0
  reflowOutput.Height() = aSize.height;
706
0
  FinishReflowChild(aChild, aPresContext, reflowOutput, nullptr, aOffset.x, aOffset.y, 0);
707
0
}
708
709
static
710
nsFrameborder GetFrameBorderHelper(nsGenericHTMLElement* aContent)
711
0
{
712
0
  if (nullptr != aContent) {
713
0
    const nsAttrValue* attr = aContent->GetParsedAttr(nsGkAtoms::frameborder);
714
0
    if (attr && attr->Type() == nsAttrValue::eEnum) {
715
0
      switch (attr->GetEnumValue())
716
0
      {
717
0
        case NS_STYLE_FRAME_YES:
718
0
        case NS_STYLE_FRAME_1:
719
0
          return eFrameborder_Yes;
720
0
721
0
        case NS_STYLE_FRAME_NO:
722
0
        case NS_STYLE_FRAME_0:
723
0
          return eFrameborder_No;
724
0
      }
725
0
    }
726
0
  }
727
0
  return eFrameborder_Notset;
728
0
}
729
730
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder()
731
0
{
732
0
  nsFrameborder result = eFrameborder_Notset;
733
0
  nsGenericHTMLElement *content = nsGenericHTMLElement::FromNode(mContent);
734
0
735
0
  if (content) {
736
0
    result = GetFrameBorderHelper(content);
737
0
  }
738
0
  if (eFrameborder_Notset == result) {
739
0
    return mParentFrameborder;
740
0
  }
741
0
  return result;
742
0
}
743
744
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent)
745
0
{
746
0
  nsFrameborder result = eFrameborder_Notset;
747
0
748
0
  nsGenericHTMLElement *content = nsGenericHTMLElement::FromNode(aContent);
749
0
750
0
  if (content) {
751
0
    result = GetFrameBorderHelper(content);
752
0
  }
753
0
  if (eFrameborder_Notset == result) {
754
0
    return GetFrameBorder();
755
0
  }
756
0
  return result;
757
0
}
758
759
nscolor nsHTMLFramesetFrame::GetBorderColor()
760
0
{
761
0
  nsGenericHTMLElement *content = nsGenericHTMLElement::FromNode(mContent);
762
0
763
0
  if (content) {
764
0
    const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::bordercolor);
765
0
    if (attr) {
766
0
      nscolor color;
767
0
      if (attr->GetColorValue(color)) {
768
0
        return color;
769
0
      }
770
0
    }
771
0
  }
772
0
773
0
  return mParentBorderColor;
774
0
}
775
776
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
777
0
{
778
0
  nsGenericHTMLElement *content = nsGenericHTMLElement::FromNode(aContent);
779
0
780
0
  if (content) {
781
0
    const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::bordercolor);
782
0
    if (attr) {
783
0
      nscolor color;
784
0
      if (attr->GetColorValue(color)) {
785
0
        return color;
786
0
      }
787
0
    }
788
0
  }
789
0
  return GetBorderColor();
790
0
}
791
792
void
793
nsHTMLFramesetFrame::Reflow(nsPresContext*           aPresContext,
794
                            ReflowOutput&     aDesiredSize,
795
                            const ReflowInput& aReflowInput,
796
                            nsReflowStatus&          aStatus)
797
0
{
798
0
  MarkInReflow();
799
0
  DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame");
800
0
  DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
801
0
  MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
802
0
803
0
  nsIPresShell *shell = aPresContext->PresShell();
804
0
  ServoStyleSet* styleSet = shell->StyleSet();
805
0
806
0
  GetParent()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
807
0
808
0
  //printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight());
809
0
  // Always get the size so that the caller knows how big we are
810
0
  GetDesiredSize(aPresContext, aReflowInput, aDesiredSize);
811
0
812
0
  nscoord width  = (aDesiredSize.Width() <= aReflowInput.AvailableWidth())
813
0
    ? aDesiredSize.Width() : aReflowInput.AvailableWidth();
814
0
  nscoord height = (aDesiredSize.Height() <= aReflowInput.AvailableHeight())
815
0
    ? aDesiredSize.Height() : aReflowInput.AvailableHeight();
816
0
817
0
  // We might be reflowed more than once with NS_FRAME_FIRST_REFLOW;
818
0
  // that's allowed.  (Though it will only happen for misuse of frameset
819
0
  // that includes it within other content.)  So measure firstTime by
820
0
  // what we care about, which is whether we've processed the data we
821
0
  // process below if firstTime is true.
822
0
  MOZ_ASSERT(!mChildFrameborder == !mChildBorderColors);
823
0
  bool firstTime = !!mChildFrameborder;
824
0
825
0
  // subtract out the width of all of the potential borders. There are
826
0
  // only borders between <frame>s. There are none on the edges (e.g the
827
0
  // leftmost <frame> has no left border).
828
0
  int32_t borderWidth = GetBorderWidth(aPresContext, true);
829
0
830
0
  width  -= (mNumCols - 1) * borderWidth;
831
0
  if (width < 0) width = 0;
832
0
833
0
  height -= (mNumRows - 1) * borderWidth;
834
0
  if (height < 0) height = 0;
835
0
836
0
  HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
837
0
  NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
838
0
  const nsFramesetSpec* rowSpecs = nullptr;
839
0
  const nsFramesetSpec* colSpecs = nullptr;
840
0
  int32_t rows = 0;
841
0
  int32_t cols = 0;
842
0
  ourContent->GetRowSpec(&rows, &rowSpecs);
843
0
  ourContent->GetColSpec(&cols, &colSpecs);
844
0
  // If the number of cols or rows has changed, the frame for the frameset
845
0
  // will be re-created.
846
0
  if (mNumRows != rows || mNumCols != cols) {
847
0
    mDrag.UnSet();
848
0
    NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
849
0
    return;
850
0
  }
851
0
852
0
  CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get());
853
0
  CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get());
854
0
855
0
  UniquePtr<bool[]>  verBordersVis; // vertical borders visibility
856
0
  UniquePtr<nscolor[]> verBorderColors;
857
0
  UniquePtr<bool[]>  horBordersVis; // horizontal borders visibility
858
0
  UniquePtr<nscolor[]> horBorderColors;
859
0
  nscolor                 borderColor = GetBorderColor();
860
0
  nsFrameborder           frameborder = GetFrameBorder();
861
0
862
0
  if (firstTime) {
863
0
    // Check for overflow in memory allocations using mNumCols and mNumRows
864
0
    // which have a maxium value of NS_MAX_FRAMESET_SPEC_COUNT.
865
0
    static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(bool),
866
0
                  "Check for overflow");
867
0
    static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscolor),
868
0
                  "Check for overflow");
869
0
870
0
    verBordersVis = MakeUnique<bool[]>(mNumCols);
871
0
    verBorderColors = MakeUnique<nscolor[]>(mNumCols);
872
0
    for (int verX  = 0; verX < mNumCols; verX++) {
873
0
      verBordersVis[verX] = false;
874
0
      verBorderColors[verX] = NO_COLOR;
875
0
    }
876
0
877
0
    horBordersVis = MakeUnique<bool[]>(mNumRows);
878
0
    horBorderColors = MakeUnique<nscolor[]>(mNumRows);
879
0
    for (int horX = 0; horX < mNumRows; horX++) {
880
0
      horBordersVis[horX] = false;
881
0
      horBorderColors[horX] = NO_COLOR;
882
0
    }
883
0
  }
884
0
885
0
  // reflow the children
886
0
  int32_t lastRow = 0;
887
0
  int32_t lastCol = 0;
888
0
  int32_t borderChildX = mNonBorderChildCount; // index of border children
889
0
  nsHTMLFramesetBorderFrame* borderFrame = nullptr;
890
0
  nsPoint offset(0,0);
891
0
  nsSize size, lastSize;
892
0
  WritingMode wm = GetWritingMode();
893
0
  LogicalSize logicalSize(wm);
894
0
  nsIFrame* child = mFrames.FirstChild();
895
0
896
0
  for (int32_t childX = 0; childX < mNonBorderChildCount; childX++) {
897
0
    nsIntPoint cellIndex;
898
0
    GetSizeOfChildAt(childX, wm, logicalSize, cellIndex);
899
0
    size = logicalSize.GetPhysicalSize(wm);
900
0
901
0
    if (lastRow != cellIndex.y) {  // changed to next row
902
0
      offset.x = 0;
903
0
      offset.y += lastSize.height;
904
0
      if (firstTime) { // create horizontal border
905
0
906
0
        RefPtr<ComputedStyle> pseudoComputedStyle;
907
0
        pseudoComputedStyle = styleSet->
908
0
          ResolveNonInheritingAnonymousBoxStyle(nsCSSAnonBoxes::horizontalFramesetBorder());
909
0
910
0
        borderFrame = new (shell) nsHTMLFramesetBorderFrame(pseudoComputedStyle,
911
0
                                                            borderWidth,
912
0
                                                            false,
913
0
                                                            false);
914
0
        borderFrame->Init(mContent, this, nullptr);
915
0
        mChildCount++;
916
0
        mFrames.AppendFrame(nullptr, borderFrame);
917
0
        mHorBorders[cellIndex.y-1] = borderFrame;
918
0
        // set the neighbors for determining drag boundaries
919
0
        borderFrame->mPrevNeighbor = lastRow;
920
0
        borderFrame->mNextNeighbor = cellIndex.y;
921
0
      } else {
922
0
        borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
923
0
        borderFrame->mWidth = borderWidth;
924
0
        borderChildX++;
925
0
      }
926
0
      nsSize borderSize(aDesiredSize.Width(), borderWidth);
927
0
      ReflowPlaceChild(borderFrame, aPresContext, aReflowInput, offset, borderSize);
928
0
      borderFrame = nullptr;
929
0
      offset.y += borderWidth;
930
0
    } else {
931
0
      if (cellIndex.x > 0) {  // moved to next col in same row
932
0
        if (0 == cellIndex.y) { // in 1st row
933
0
          if (firstTime) { // create vertical border
934
0
935
0
            RefPtr<ComputedStyle> pseudoComputedStyle;
936
0
            pseudoComputedStyle = styleSet->
937
0
              ResolveNonInheritingAnonymousBoxStyle(nsCSSAnonBoxes::verticalFramesetBorder());
938
0
939
0
            borderFrame = new (shell) nsHTMLFramesetBorderFrame(pseudoComputedStyle,
940
0
                                                                borderWidth,
941
0
                                                                true,
942
0
                                                                false);
943
0
            borderFrame->Init(mContent, this, nullptr);
944
0
            mChildCount++;
945
0
            mFrames.AppendFrame(nullptr, borderFrame);
946
0
            mVerBorders[cellIndex.x-1] = borderFrame;
947
0
            // set the neighbors for determining drag boundaries
948
0
            borderFrame->mPrevNeighbor = lastCol;
949
0
            borderFrame->mNextNeighbor = cellIndex.x;
950
0
          } else {
951
0
            borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
952
0
            borderFrame->mWidth = borderWidth;
953
0
            borderChildX++;
954
0
          }
955
0
          nsSize borderSize(borderWidth, aDesiredSize.Height());
956
0
          ReflowPlaceChild(borderFrame, aPresContext, aReflowInput, offset, borderSize);
957
0
          borderFrame = nullptr;
958
0
        }
959
0
        offset.x += borderWidth;
960
0
      }
961
0
    }
962
0
963
0
    ReflowPlaceChild(child, aPresContext, aReflowInput, offset, size, &cellIndex);
964
0
965
0
    if (firstTime) {
966
0
      int32_t childVis;
967
0
      nsHTMLFramesetFrame* framesetFrame = do_QueryFrame(child);
968
0
      nsSubDocumentFrame* subdocFrame;
969
0
      if (framesetFrame) {
970
0
        childVis = framesetFrame->mEdgeVisibility;
971
0
        mChildBorderColors[childX] = framesetFrame->mEdgeColors;
972
0
      } else if ((subdocFrame = do_QueryFrame(child))) {
973
0
        if (eFrameborder_Yes == mChildFrameborder[childX]) {
974
0
          childVis = ALL_VIS;
975
0
        } else if (eFrameborder_No == mChildFrameborder[childX]) {
976
0
          childVis = NONE_VIS;
977
0
        } else {  // notset
978
0
          childVis = (eFrameborder_No == frameborder) ? NONE_VIS : ALL_VIS;
979
0
        }
980
0
      } else {  // blank
981
#ifdef DEBUG
982
        nsHTMLFramesetBlankFrame* blank = do_QueryFrame(child);
983
        MOZ_ASSERT(blank, "unexpected child frame type");
984
#endif
985
0
        childVis = NONE_VIS;
986
0
      }
987
0
      nsBorderColor childColors = mChildBorderColors[childX];
988
0
      // set the visibility, color of our edge borders based on children
989
0
      if (0 == cellIndex.x) {
990
0
        if (!(mEdgeVisibility & LEFT_VIS)) {
991
0
          mEdgeVisibility |= (LEFT_VIS & childVis);
992
0
        }
993
0
        if (NO_COLOR == mEdgeColors.mLeft) {
994
0
          mEdgeColors.mLeft = childColors.mLeft;
995
0
        }
996
0
      }
997
0
      if (0 == cellIndex.y) {
998
0
        if (!(mEdgeVisibility & TOP_VIS)) {
999
0
          mEdgeVisibility |= (TOP_VIS & childVis);
1000
0
        }
1001
0
        if (NO_COLOR == mEdgeColors.mTop) {
1002
0
          mEdgeColors.mTop = childColors.mTop;
1003
0
        }
1004
0
      }
1005
0
      if (mNumCols-1 == cellIndex.x) {
1006
0
        if (!(mEdgeVisibility & RIGHT_VIS)) {
1007
0
          mEdgeVisibility |= (RIGHT_VIS & childVis);
1008
0
        }
1009
0
        if (NO_COLOR == mEdgeColors.mRight) {
1010
0
          mEdgeColors.mRight = childColors.mRight;
1011
0
        }
1012
0
      }
1013
0
      if (mNumRows-1 == cellIndex.y) {
1014
0
        if (!(mEdgeVisibility & BOTTOM_VIS)) {
1015
0
          mEdgeVisibility |= (BOTTOM_VIS & childVis);
1016
0
        }
1017
0
        if (NO_COLOR == mEdgeColors.mBottom) {
1018
0
          mEdgeColors.mBottom = childColors.mBottom;
1019
0
        }
1020
0
      }
1021
0
      // set the visibility of borders that the child may affect
1022
0
      if (childVis & RIGHT_VIS) {
1023
0
        verBordersVis[cellIndex.x] = true;
1024
0
      }
1025
0
      if (childVis & BOTTOM_VIS) {
1026
0
        horBordersVis[cellIndex.y] = true;
1027
0
      }
1028
0
      if ((cellIndex.x > 0) && (childVis & LEFT_VIS)) {
1029
0
        verBordersVis[cellIndex.x-1] = true;
1030
0
      }
1031
0
      if ((cellIndex.y > 0) && (childVis & TOP_VIS)) {
1032
0
        horBordersVis[cellIndex.y-1] = true;
1033
0
      }
1034
0
      // set the colors of borders that the child may affect
1035
0
      if (NO_COLOR == verBorderColors[cellIndex.x]) {
1036
0
        verBorderColors[cellIndex.x] = mChildBorderColors[childX].mRight;
1037
0
      }
1038
0
      if (NO_COLOR == horBorderColors[cellIndex.y]) {
1039
0
        horBorderColors[cellIndex.y] = mChildBorderColors[childX].mBottom;
1040
0
      }
1041
0
      if ((cellIndex.x > 0) && (NO_COLOR == verBorderColors[cellIndex.x-1])) {
1042
0
        verBorderColors[cellIndex.x-1] = mChildBorderColors[childX].mLeft;
1043
0
      }
1044
0
      if ((cellIndex.y > 0) && (NO_COLOR == horBorderColors[cellIndex.y-1])) {
1045
0
        horBorderColors[cellIndex.y-1] = mChildBorderColors[childX].mTop;
1046
0
      }
1047
0
    }
1048
0
    lastRow  = cellIndex.y;
1049
0
    lastCol  = cellIndex.x;
1050
0
    lastSize = size;
1051
0
    offset.x += size.width;
1052
0
    child = child->GetNextSibling();
1053
0
  }
1054
0
1055
0
  if (firstTime) {
1056
0
    nscolor childColor;
1057
0
    // set the visibility, color, mouse sensitivity of borders
1058
0
    for (int verX = 0; verX < mNumCols-1; verX++) {
1059
0
      if (mVerBorders[verX]) {
1060
0
        mVerBorders[verX]->SetVisibility(verBordersVis[verX]);
1061
0
        SetBorderResize(mVerBorders[verX]);
1062
0
        childColor = (NO_COLOR == verBorderColors[verX]) ? borderColor : verBorderColors[verX];
1063
0
        mVerBorders[verX]->SetColor(childColor);
1064
0
      }
1065
0
    }
1066
0
    for (int horX = 0; horX < mNumRows-1; horX++) {
1067
0
      if (mHorBorders[horX]) {
1068
0
        mHorBorders[horX]->SetVisibility(horBordersVis[horX]);
1069
0
        SetBorderResize(mHorBorders[horX]);
1070
0
        childColor = (NO_COLOR == horBorderColors[horX]) ? borderColor : horBorderColors[horX];
1071
0
        mHorBorders[horX]->SetColor(childColor);
1072
0
      }
1073
0
    }
1074
0
1075
0
    mChildFrameborder.reset();
1076
0
    mChildBorderColors.reset();
1077
0
  }
1078
0
1079
0
  mDrag.UnSet();
1080
0
1081
0
  aDesiredSize.SetOverflowAreasToDesiredBounds();
1082
0
  FinishAndStoreOverflow(&aDesiredSize);
1083
0
1084
0
  NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
1085
0
}
1086
1087
#ifdef DEBUG_FRAME_DUMP
1088
nsresult
1089
nsHTMLFramesetFrame::GetFrameName(nsAString& aResult) const
1090
{
1091
  return MakeFrameName(NS_LITERAL_STRING("Frameset"), aResult);
1092
}
1093
#endif
1094
1095
bool
1096
nsHTMLFramesetFrame::CanResize(bool aVertical,
1097
                               bool aLeft)
1098
0
{
1099
0
  int32_t childX;
1100
0
  int32_t startX;
1101
0
  if (aVertical) {
1102
0
    startX = (aLeft) ? 0 : mNumCols-1;
1103
0
    for (childX = startX; childX < mNonBorderChildCount; childX += mNumCols) {
1104
0
      if (!CanChildResize(aVertical, aLeft, childX)) {
1105
0
        return false;
1106
0
      }
1107
0
    }
1108
0
  } else {
1109
0
    startX = (aLeft) ? 0 : (mNumRows - 1) * mNumCols;
1110
0
    int32_t endX = startX + mNumCols;
1111
0
    for (childX = startX; childX < endX; childX++) {
1112
0
      if (!CanChildResize(aVertical, aLeft, childX)) {
1113
0
        return false;
1114
0
      }
1115
0
    }
1116
0
  }
1117
0
  return true;
1118
0
}
1119
1120
bool
1121
nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame)
1122
0
{
1123
0
  nsIContent* content = aChildFrame->GetContent();
1124
0
1125
0
  return content &&
1126
0
    content->IsElement() &&
1127
0
    content->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::noresize);
1128
0
}
1129
1130
bool
1131
nsHTMLFramesetFrame::CanChildResize(bool aVertical, bool aLeft, int32_t aChildX)
1132
0
{
1133
0
  nsIFrame* child = mFrames.FrameAt(aChildX);
1134
0
  nsHTMLFramesetFrame* frameset = do_QueryFrame(child);
1135
0
  return frameset ? frameset->CanResize(aVertical, aLeft) : !GetNoResize(child);
1136
0
}
1137
1138
// This calculates and sets the resizability of all border frames
1139
1140
void
1141
nsHTMLFramesetFrame::RecalculateBorderResize()
1142
0
{
1143
0
  if (!mContent) {
1144
0
    return;
1145
0
  }
1146
0
1147
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT,
1148
0
                "Check for overflow");
1149
0
  static_assert(NS_MAX_FRAMESET_SPEC_COUNT
1150
0
                   < UINT_MAX / sizeof(int32_t) / NS_MAX_FRAMESET_SPEC_COUNT,
1151
0
                "Check for overflow");
1152
0
  // set the visibility and mouse sensitivity of borders
1153
0
  int32_t verX;
1154
0
  for (verX = 0; verX < mNumCols-1; verX++) {
1155
0
    if (mVerBorders[verX]) {
1156
0
      mVerBorders[verX]->mCanResize = true;
1157
0
      SetBorderResize(mVerBorders[verX]);
1158
0
    }
1159
0
  }
1160
0
  int32_t horX;
1161
0
  for (horX = 0; horX < mNumRows-1; horX++) {
1162
0
    if (mHorBorders[horX]) {
1163
0
      mHorBorders[horX]->mCanResize = true;
1164
0
      SetBorderResize(mHorBorders[horX]);
1165
0
    }
1166
0
  }
1167
0
}
1168
1169
void
1170
nsHTMLFramesetFrame::SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame)
1171
0
{
1172
0
  if (aBorderFrame->mVertical) {
1173
0
    for (int rowX = 0; rowX < mNumRows; rowX++) {
1174
0
      int32_t childX = aBorderFrame->mPrevNeighbor + (rowX * mNumCols);
1175
0
      if (!CanChildResize(true, false, childX) ||
1176
0
          !CanChildResize(true, true, childX+1)) {
1177
0
        aBorderFrame->mCanResize = false;
1178
0
      }
1179
0
    }
1180
0
  } else {
1181
0
    int32_t childX = aBorderFrame->mPrevNeighbor * mNumCols;
1182
0
    int32_t endX   = childX + mNumCols;
1183
0
    for (; childX < endX; childX++) {
1184
0
      if (!CanChildResize(false, false, childX)) {
1185
0
        aBorderFrame->mCanResize = false;
1186
0
      }
1187
0
    }
1188
0
    endX = endX + mNumCols;
1189
0
    for (; childX < endX; childX++) {
1190
0
      if (!CanChildResize(false, true, childX)) {
1191
0
        aBorderFrame->mCanResize = false;
1192
0
      }
1193
0
    }
1194
0
  }
1195
0
}
1196
1197
void
1198
nsHTMLFramesetFrame::StartMouseDrag(nsPresContext*             aPresContext,
1199
                                    nsHTMLFramesetBorderFrame* aBorder,
1200
                                    WidgetGUIEvent*            aEvent)
1201
0
{
1202
#if 0
1203
  int32_t index;
1204
  IndexOf(aBorder, index);
1205
  NS_ASSERTION((nullptr != aBorder) && (index >= 0), "invalid dragger");
1206
#endif
1207
1208
0
  nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED);
1209
0
1210
0
  mDragger = aBorder;
1211
0
1212
0
  mFirstDragPoint = aEvent->mRefPoint;
1213
0
1214
0
  // Store the original frame sizes
1215
0
  if (mDragger->mVertical) {
1216
0
    mPrevNeighborOrigSize = mColSizes[mDragger->mPrevNeighbor];
1217
0
    mNextNeighborOrigSize = mColSizes[mDragger->mNextNeighbor];
1218
0
  } else {
1219
0
    mPrevNeighborOrigSize = mRowSizes[mDragger->mPrevNeighbor];
1220
0
    mNextNeighborOrigSize = mRowSizes[mDragger->mNextNeighbor];
1221
0
  }
1222
0
1223
0
  gDragInProgress = true;
1224
0
}
1225
1226
1227
void
1228
nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
1229
                               WidgetGUIEvent* aEvent)
1230
0
{
1231
0
  // if the capture ended, reset the drag state
1232
0
  if (nsIPresShell::GetCapturingContent() != GetContent()) {
1233
0
    mDragger = nullptr;
1234
0
    gDragInProgress = false;
1235
0
    return;
1236
0
  }
1237
0
1238
0
  int32_t change; // measured positive from left-to-right or top-to-bottom
1239
0
  AutoWeakFrame weakFrame(this);
1240
0
  if (mDragger->mVertical) {
1241
0
    change = aPresContext->DevPixelsToAppUnits(
1242
0
                             aEvent->mRefPoint.x - mFirstDragPoint.x);
1243
0
    if (change > mNextNeighborOrigSize - mMinDrag) {
1244
0
      change = mNextNeighborOrigSize - mMinDrag;
1245
0
    } else if (change <= mMinDrag - mPrevNeighborOrigSize) {
1246
0
      change = mMinDrag - mPrevNeighborOrigSize;
1247
0
    }
1248
0
    mColSizes[mDragger->mPrevNeighbor] = mPrevNeighborOrigSize + change;
1249
0
    mColSizes[mDragger->mNextNeighbor] = mNextNeighborOrigSize - change;
1250
0
1251
0
    if (change != 0) {
1252
0
      // Recompute the specs from the new sizes.
1253
0
      nscoord width = mRect.width - (mNumCols - 1) * GetBorderWidth(aPresContext, true);
1254
0
      HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
1255
0
      NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
1256
0
      const nsFramesetSpec* colSpecs = nullptr;
1257
0
      ourContent->GetColSpec(&mNumCols, &colSpecs);
1258
0
      nsAutoString newColAttr;
1259
0
      GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get(),
1260
0
                     newColAttr);
1261
0
      // Setting the attr will trigger a reflow
1262
0
      mContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::cols,
1263
0
                                     newColAttr, true);
1264
0
    }
1265
0
  } else {
1266
0
    change = aPresContext->DevPixelsToAppUnits(
1267
0
                             aEvent->mRefPoint.y - mFirstDragPoint.y);
1268
0
    if (change > mNextNeighborOrigSize - mMinDrag) {
1269
0
      change = mNextNeighborOrigSize - mMinDrag;
1270
0
    } else if (change <= mMinDrag - mPrevNeighborOrigSize) {
1271
0
      change = mMinDrag - mPrevNeighborOrigSize;
1272
0
    }
1273
0
    mRowSizes[mDragger->mPrevNeighbor] = mPrevNeighborOrigSize + change;
1274
0
    mRowSizes[mDragger->mNextNeighbor] = mNextNeighborOrigSize - change;
1275
0
1276
0
    if (change != 0) {
1277
0
      // Recompute the specs from the new sizes.
1278
0
      nscoord height = mRect.height - (mNumRows - 1) * GetBorderWidth(aPresContext, true);
1279
0
      HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
1280
0
      NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
1281
0
      const nsFramesetSpec* rowSpecs = nullptr;
1282
0
      ourContent->GetRowSpec(&mNumRows, &rowSpecs);
1283
0
      nsAutoString newRowAttr;
1284
0
      GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get(),
1285
0
                     newRowAttr);
1286
0
      // Setting the attr will trigger a reflow
1287
0
      mContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::rows,
1288
0
                                     newRowAttr, true);
1289
0
    }
1290
0
  }
1291
0
1292
0
  NS_ENSURE_TRUE_VOID(weakFrame.IsAlive());
1293
0
  if (change != 0) {
1294
0
    mDrag.Reset(mDragger->mVertical, mDragger->mPrevNeighbor, change, this);
1295
0
  }
1296
0
}
1297
1298
void
1299
nsHTMLFramesetFrame::EndMouseDrag(nsPresContext* aPresContext)
1300
0
{
1301
0
  nsIPresShell::SetCapturingContent(nullptr, 0);
1302
0
  mDragger = nullptr;
1303
0
  gDragInProgress = false;
1304
0
}
1305
1306
nsIFrame*
1307
NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
1308
0
{
1309
#ifdef DEBUG
1310
  const nsStyleDisplay* disp = aStyle->StyleDisplay();
1311
  NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
1312
               "Framesets should not be positioned and should not float");
1313
#endif
1314
1315
0
  return new (aPresShell) nsHTMLFramesetFrame(aStyle);
1316
0
}
1317
1318
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
1319
1320
/*******************************************************************************
1321
 * nsHTMLFramesetBorderFrame
1322
 ******************************************************************************/
1323
nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(ComputedStyle* aStyle,
1324
                                                     int32_t aWidth,
1325
                                                     bool aVertical,
1326
                                                     bool aVisibility)
1327
  : nsLeafFrame(aStyle, kClassID)
1328
  , mWidth(aWidth)
1329
  , mVertical(aVertical)
1330
  , mVisibility(aVisibility)
1331
0
{
1332
0
   mCanResize    = true;
1333
0
   mColor        = NO_COLOR;
1334
0
   mPrevNeighbor = 0;
1335
0
   mNextNeighbor = 0;
1336
0
}
1337
1338
nsHTMLFramesetBorderFrame::~nsHTMLFramesetBorderFrame()
1339
0
{
1340
0
  //printf("nsHTMLFramesetBorderFrame destructor %p \n", this);
1341
0
}
1342
1343
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetBorderFrame)
1344
1345
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicISize()
1346
0
{
1347
0
  // No intrinsic width
1348
0
  return 0;
1349
0
}
1350
1351
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicBSize()
1352
0
{
1353
0
  // No intrinsic height
1354
0
  return 0;
1355
0
}
1356
1357
void nsHTMLFramesetBorderFrame::SetVisibility(bool aVisibility)
1358
0
{
1359
0
  mVisibility = aVisibility;
1360
0
}
1361
1362
void nsHTMLFramesetBorderFrame::SetColor(nscolor aColor)
1363
0
{
1364
0
  mColor = aColor;
1365
0
}
1366
1367
1368
void
1369
nsHTMLFramesetBorderFrame::Reflow(nsPresContext*           aPresContext,
1370
                                  ReflowOutput&     aDesiredSize,
1371
                                  const ReflowInput& aReflowInput,
1372
                                  nsReflowStatus&          aStatus)
1373
0
{
1374
0
  DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBorderFrame");
1375
0
  DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
1376
0
  MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
1377
0
1378
0
  // Override Reflow(), since we don't want to deal with what our
1379
0
  // computed values are.
1380
0
  SizeToAvailSize(aReflowInput, aDesiredSize);
1381
0
1382
0
  aDesiredSize.SetOverflowAreasToDesiredBounds();
1383
0
}
1384
1385
class nsDisplayFramesetBorder : public nsDisplayItem {
1386
public:
1387
  nsDisplayFramesetBorder(nsDisplayListBuilder* aBuilder,
1388
                          nsHTMLFramesetBorderFrame* aFrame)
1389
0
    : nsDisplayItem(aBuilder, aFrame) {
1390
0
    MOZ_COUNT_CTOR(nsDisplayFramesetBorder);
1391
0
  }
1392
#ifdef NS_BUILD_REFCNT_LOGGING
1393
  virtual ~nsDisplayFramesetBorder() {
1394
    MOZ_COUNT_DTOR(nsDisplayFramesetBorder);
1395
  }
1396
#endif
1397
1398
  // REVIEW: see old GetFrameForPoint
1399
  // Receives events in its bounds
1400
  virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
1401
                       HitTestState* aState,
1402
0
                       nsTArray<nsIFrame*> *aOutFrames) override {
1403
0
    aOutFrames->AppendElement(mFrame);
1404
0
  }
1405
  virtual void Paint(nsDisplayListBuilder* aBuilder,
1406
                     gfxContext* aCtx) override;
1407
  NS_DISPLAY_DECL_NAME("FramesetBorder", TYPE_FRAMESET_BORDER)
1408
};
1409
1410
void nsDisplayFramesetBorder::Paint(nsDisplayListBuilder* aBuilder,
1411
                                    gfxContext* aCtx)
1412
0
{
1413
0
  static_cast<nsHTMLFramesetBorderFrame*>(mFrame)->
1414
0
    PaintBorder(aCtx->GetDrawTarget(), ToReferenceFrame());
1415
0
}
1416
1417
void
1418
nsHTMLFramesetBorderFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
1419
                                            const nsDisplayListSet& aLists)
1420
0
{
1421
0
  aLists.Content()->AppendToTop(
1422
0
    MakeDisplayItem<nsDisplayFramesetBorder>(aBuilder, this));
1423
0
}
1424
1425
void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget,
1426
                                            nsPoint aPt)
1427
0
{
1428
0
  nscoord widthInPixels = nsPresContext::AppUnitsToIntCSSPixels(mWidth);
1429
0
  nscoord pixelWidth    = nsPresContext::CSSPixelsToAppUnits(1);
1430
0
1431
0
  if (widthInPixels <= 0)
1432
0
    return;
1433
0
1434
0
  ColorPattern bgColor(ToDeviceColor(
1435
0
                 LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetBackground,
1436
0
                                       NS_RGB(200, 200, 200))));
1437
0
1438
0
  ColorPattern fgColor(ToDeviceColor(
1439
0
                 LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetForeground,
1440
0
                                       NS_RGB(0, 0, 0))));
1441
0
1442
0
  ColorPattern hltColor(ToDeviceColor(
1443
0
                 LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DHighlight,
1444
0
                                       NS_RGB(255, 255, 255))));
1445
0
1446
0
  ColorPattern sdwColor(ToDeviceColor(
1447
0
                 LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DShadow,
1448
0
                                       NS_RGB(128, 128, 128))));
1449
0
1450
0
  ColorPattern color(ToDeviceColor(NS_RGB(255, 255, 255))); // default to white
1451
0
  if (mVisibility) {
1452
0
    color = (NO_COLOR == mColor) ? bgColor :
1453
0
                                   ColorPattern(ToDeviceColor(mColor));
1454
0
  }
1455
0
1456
0
  int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
1457
0
1458
0
  Point toRefFrame = NSPointToPoint(aPt, appUnitsPerDevPixel);
1459
0
1460
0
  AutoRestoreTransform autoRestoreTransform(aDrawTarget);
1461
0
  aDrawTarget->SetTransform(
1462
0
    aDrawTarget->GetTransform().PreTranslate(toRefFrame));
1463
0
1464
0
  nsPoint start(0, 0);
1465
0
  nsPoint end = mVertical ? nsPoint(0, mRect.height) : nsPoint(mRect.width, 0);
1466
0
1467
0
  // draw grey or white first
1468
0
  for (int i = 0; i < widthInPixels; i++) {
1469
0
    StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
1470
0
                           color);
1471
0
    if (mVertical) {
1472
0
      start.x += pixelWidth;
1473
0
      end.x =  start.x;
1474
0
    } else {
1475
0
      start.y += pixelWidth;
1476
0
      end.y =  start.y;
1477
0
    }
1478
0
  }
1479
0
1480
0
  if (!mVisibility)
1481
0
    return;
1482
0
1483
0
  if (widthInPixels >= 5) {
1484
0
    start.x = (mVertical) ? pixelWidth : 0;
1485
0
    start.y = (mVertical) ? 0 : pixelWidth;
1486
0
    end.x   = (mVertical) ? start.x : mRect.width;
1487
0
    end.y   = (mVertical) ? mRect.height : start.y;
1488
0
    StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
1489
0
                           hltColor);
1490
0
  }
1491
0
1492
0
  if (widthInPixels >= 2) {
1493
0
    start.x = (mVertical) ? mRect.width - (2 * pixelWidth) : 0;
1494
0
    start.y = (mVertical) ? 0 : mRect.height - (2 * pixelWidth);
1495
0
    end.x   = (mVertical) ? start.x : mRect.width;
1496
0
    end.y   = (mVertical) ? mRect.height : start.y;
1497
0
    StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
1498
0
                           sdwColor);
1499
0
  }
1500
0
1501
0
  if (widthInPixels >= 1) {
1502
0
    start.x = (mVertical) ? mRect.width - pixelWidth : 0;
1503
0
    start.y = (mVertical) ? 0 : mRect.height - pixelWidth;
1504
0
    end.x   = (mVertical) ? start.x : mRect.width;
1505
0
    end.y   = (mVertical) ? mRect.height : start.y;
1506
0
    StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
1507
0
                           fgColor);
1508
0
  }
1509
0
}
1510
1511
1512
nsresult
1513
nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
1514
                                       WidgetGUIEvent* aEvent,
1515
                                       nsEventStatus* aEventStatus)
1516
0
{
1517
0
  NS_ENSURE_ARG_POINTER(aEventStatus);
1518
0
  *aEventStatus = nsEventStatus_eIgnore;
1519
0
1520
0
  //XXX Mouse setting logic removed.  The remaining logic should also move.
1521
0
  if (!mCanResize) {
1522
0
    return NS_OK;
1523
0
  }
1524
0
1525
0
  if (aEvent->mMessage == eMouseDown &&
1526
0
      aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
1527
0
    nsHTMLFramesetFrame* parentFrame = do_QueryFrame(GetParent());
1528
0
    if (parentFrame) {
1529
0
      parentFrame->StartMouseDrag(aPresContext, this, aEvent);
1530
0
      *aEventStatus = nsEventStatus_eConsumeNoDefault;
1531
0
    }
1532
0
  }
1533
0
  return NS_OK;
1534
0
}
1535
1536
nsresult
1537
nsHTMLFramesetBorderFrame::GetCursor(const nsPoint&    aPoint,
1538
                                     nsIFrame::Cursor& aCursor)
1539
0
{
1540
0
  aCursor.mLoading = false;
1541
0
  if (!mCanResize) {
1542
0
    aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
1543
0
  } else {
1544
0
    aCursor.mCursor = (mVertical) ? NS_STYLE_CURSOR_EW_RESIZE : NS_STYLE_CURSOR_NS_RESIZE;
1545
0
  }
1546
0
  return NS_OK;
1547
0
}
1548
1549
#ifdef DEBUG_FRAME_DUMP
1550
nsresult nsHTMLFramesetBorderFrame::GetFrameName(nsAString& aResult) const
1551
{
1552
  return MakeFrameName(NS_LITERAL_STRING("FramesetBorder"), aResult);
1553
}
1554
#endif
1555
1556
/*******************************************************************************
1557
 * nsHTMLFramesetBlankFrame
1558
 ******************************************************************************/
1559
1560
0
NS_QUERYFRAME_HEAD(nsHTMLFramesetBlankFrame)
1561
0
  NS_QUERYFRAME_ENTRY(nsHTMLFramesetBlankFrame)
1562
0
NS_QUERYFRAME_TAIL_INHERITING(nsLeafFrame)
1563
1564
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetBlankFrame)
1565
1566
nsHTMLFramesetBlankFrame::~nsHTMLFramesetBlankFrame()
1567
0
{
1568
0
  //printf("nsHTMLFramesetBlankFrame destructor %p \n", this);
1569
0
}
1570
1571
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicISize()
1572
0
{
1573
0
  // No intrinsic width
1574
0
  return 0;
1575
0
}
1576
1577
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicBSize()
1578
0
{
1579
0
  // No intrinsic height
1580
0
  return 0;
1581
0
}
1582
1583
void
1584
nsHTMLFramesetBlankFrame::Reflow(nsPresContext*           aPresContext,
1585
                                 ReflowOutput&     aDesiredSize,
1586
                                 const ReflowInput& aReflowInput,
1587
                                 nsReflowStatus&          aStatus)
1588
0
{
1589
0
  DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBlankFrame");
1590
0
  MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
1591
0
1592
0
  // Override Reflow(), since we don't want to deal with what our
1593
0
  // computed values are.
1594
0
  SizeToAvailSize(aReflowInput, aDesiredSize);
1595
0
1596
0
  aDesiredSize.SetOverflowAreasToDesiredBounds();
1597
0
}
1598
1599
class nsDisplayFramesetBlank : public nsDisplayItem {
1600
public:
1601
  nsDisplayFramesetBlank(nsDisplayListBuilder* aBuilder,
1602
                         nsIFrame* aFrame) :
1603
0
    nsDisplayItem(aBuilder, aFrame) {
1604
0
    MOZ_COUNT_CTOR(nsDisplayFramesetBlank);
1605
0
  }
1606
#ifdef NS_BUILD_REFCNT_LOGGING
1607
  virtual ~nsDisplayFramesetBlank() {
1608
    MOZ_COUNT_DTOR(nsDisplayFramesetBlank);
1609
  }
1610
#endif
1611
1612
  virtual void Paint(nsDisplayListBuilder* aBuilder,
1613
                     gfxContext* aCtx) override;
1614
  NS_DISPLAY_DECL_NAME("FramesetBlank", TYPE_FRAMESET_BLANK)
1615
};
1616
1617
void nsDisplayFramesetBlank::Paint(nsDisplayListBuilder* aBuilder,
1618
                                   gfxContext* aCtx)
1619
0
{
1620
0
  DrawTarget* drawTarget = aCtx->GetDrawTarget();
1621
0
  int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
1622
0
  Rect rect =
1623
0
    NSRectToSnappedRect(GetPaintRect(), appUnitsPerDevPixel, *drawTarget);
1624
0
  ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
1625
0
  drawTarget->FillRect(rect, white);
1626
0
}
1627
1628
void
1629
nsHTMLFramesetBlankFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
1630
                                           const nsDisplayListSet& aLists)
1631
0
{
1632
0
  aLists.Content()->AppendToTop(
1633
0
    MakeDisplayItem<nsDisplayFramesetBlank>(aBuilder, this));
1634
0
}