2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sw=2 et tw=78: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* interface for all rendering objects */
|
|
|
|
|
|
|
|
#ifndef nsIFrame_h___
|
|
|
|
#define nsIFrame_h___
|
|
|
|
|
2010-12-01 11:42:27 -08:00
|
|
|
#ifndef MOZILLA_INTERNAL_API
|
|
|
|
#error This header/class should only be used within Mozilla code. It should not be used by extensions.
|
|
|
|
#endif
|
|
|
|
|
2012-03-23 08:21:44 -07:00
|
|
|
#define MAX_REFLOW_DEPTH 200
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* nsIFrame is in the process of being deCOMtaminated, i.e., this file is eventually
|
|
|
|
going to be eliminated, and all callers will use nsFrame instead. At the moment
|
|
|
|
we're midway through this process, so you will see inlined functions and member
|
|
|
|
variables in this file. -dwh */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2009-01-12 11:20:59 -08:00
|
|
|
#include "nsQueryFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStyleContext.h"
|
2012-08-02 04:38:51 -07:00
|
|
|
#include "nsStyleStruct.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHTMLReflowMetrics.h"
|
2009-07-28 05:51:08 -07:00
|
|
|
#include "nsFrameList.h"
|
2011-08-24 13:54:29 -07:00
|
|
|
#include "mozilla/layout/FrameChildList.h"
|
2010-03-28 18:46:55 -07:00
|
|
|
#include "FramePropertyTable.h"
|
2013-01-28 16:33:17 -08:00
|
|
|
#include "mozilla/TypedEnum.h"
|
2013-08-06 13:19:11 -07:00
|
|
|
#include "nsDirection.h"
|
2013-12-27 09:58:46 -08:00
|
|
|
#include "WritingModes.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2013-08-14 04:19:55 -07:00
|
|
|
#include "nsITheme.h"
|
2013-08-14 04:33:03 -07:00
|
|
|
#include "gfx3DMatrix.h"
|
2013-09-30 14:26:04 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-28 14:53:44 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "mozilla/a11y/AccTypes.h"
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* New rules of reflow:
|
|
|
|
* 1. you get a WillReflow() followed by a Reflow() followed by a DidReflow() in order
|
|
|
|
* (no separate pass over the tree)
|
|
|
|
* 2. it's the parent frame's responsibility to size/position the child's view (not
|
|
|
|
* the child frame's responsibility as it is today) during reflow (and before
|
|
|
|
* sending the DidReflow() notification)
|
|
|
|
* 3. positioning of child frames (and their views) is done on the way down the tree,
|
|
|
|
* and sizing of child frames (and their views) on the way back up
|
|
|
|
* 4. if you move a frame (outside of the reflow process, or after reflowing it),
|
|
|
|
* then you must make sure that its view (or its child frame's views) are re-positioned
|
|
|
|
* as well. It's reasonable to not position the view until after all reflowing the
|
|
|
|
* entire line, for example, but the frame should still be positioned and sized (and
|
|
|
|
* the view sized) during the reflow (i.e., before sending the DidReflow() notification)
|
|
|
|
* 5. the view system handles moving of widgets, i.e., it's not our problem
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct nsHTMLReflowState;
|
|
|
|
class nsHTMLReflowCommand;
|
|
|
|
|
2012-08-05 20:00:56 -07:00
|
|
|
struct gfxMatrix;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIAtom;
|
|
|
|
class nsPresContext;
|
|
|
|
class nsIPresShell;
|
2011-04-07 18:04:40 -07:00
|
|
|
class nsRenderingContext;
|
2013-01-03 05:23:11 -08:00
|
|
|
class nsView;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIWidget;
|
|
|
|
class nsIDOMRange;
|
|
|
|
class nsISelectionController;
|
|
|
|
class nsBoxLayoutState;
|
2011-07-11 07:05:10 -07:00
|
|
|
class nsBoxLayout;
|
2008-10-30 12:17:59 -07:00
|
|
|
class nsILineIterator;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsDisplayListBuilder;
|
|
|
|
class nsDisplayListSet;
|
|
|
|
class nsDisplayList;
|
2007-08-03 18:12:24 -07:00
|
|
|
class gfxSkipChars;
|
|
|
|
class gfxSkipCharsIterator;
|
2007-10-12 01:30:54 -07:00
|
|
|
class gfxContext;
|
2007-09-17 20:00:16 -07:00
|
|
|
class nsLineList_iterator;
|
2011-04-27 16:41:43 -07:00
|
|
|
class nsAbsoluteContainingBlock;
|
2013-08-23 15:15:45 -07:00
|
|
|
class nsIContent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct nsPeekOffsetStruct;
|
|
|
|
struct nsPoint;
|
|
|
|
struct nsRect;
|
|
|
|
struct nsSize;
|
|
|
|
struct nsMargin;
|
2009-08-04 18:38:10 -07:00
|
|
|
struct CharacterDataChangeInfo;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-27 16:59:47 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class Layer;
|
|
|
|
}
|
2013-12-29 22:50:07 -08:00
|
|
|
|
|
|
|
namespace gfx {
|
|
|
|
class Matrix;
|
|
|
|
}
|
2011-03-27 16:59:47 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Indication of how the frame can be split. This is used when doing runaround
|
|
|
|
* of floats, and when pulling up child frames from a next-in-flow.
|
|
|
|
*
|
|
|
|
* The choices are splittable, not splittable at all, and splittable in
|
|
|
|
* a non-rectangular fashion. This last type only applies to block-level
|
|
|
|
* elements, and indicates whether splitting can be used when doing runaround.
|
|
|
|
* If you can split across page boundaries, but you expect each continuing
|
|
|
|
* frame to be the same width then return frSplittable and not
|
|
|
|
* frSplittableNonRectangular.
|
|
|
|
*
|
|
|
|
* @see #GetSplittableType()
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef uint32_t nsSplittableType;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_FRAME_NOT_SPLITTABLE 0 // Note: not a bit!
|
|
|
|
#define NS_FRAME_SPLITTABLE 0x1
|
|
|
|
#define NS_FRAME_SPLITTABLE_NON_RECTANGULAR 0x3
|
|
|
|
|
|
|
|
#define NS_FRAME_IS_SPLITTABLE(type)\
|
|
|
|
(0 != ((type) & NS_FRAME_SPLITTABLE))
|
|
|
|
|
|
|
|
#define NS_FRAME_IS_NOT_SPLITTABLE(type)\
|
|
|
|
(0 == ((type) & NS_FRAME_SPLITTABLE))
|
|
|
|
|
|
|
|
#define NS_INTRINSIC_WIDTH_UNKNOWN nscoord_MIN
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frame state bits. Any bits not listed here are reserved for future
|
|
|
|
* extensions, but must be stored by the frames.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef uint64_t nsFrameState;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-08 22:28:14 -07:00
|
|
|
#define NS_FRAME_STATE_BIT(n_) (nsFrameState(1) << (n_))
|
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
#define NS_FRAME_IN_REFLOW NS_FRAME_STATE_BIT(0)
|
2007-06-19 22:12:35 -07:00
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
// This bit is set when a frame is created. After it has been reflowed
|
|
|
|
// once (during the DidReflow with a finished state) the bit is
|
|
|
|
// cleared.
|
|
|
|
#define NS_FRAME_FIRST_REFLOW NS_FRAME_STATE_BIT(1)
|
2007-06-19 22:12:35 -07:00
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
// For a continuation frame, if this bit is set, then this a "fluid"
|
|
|
|
// continuation, i.e., across a line boundary. Otherwise it's a "hard"
|
|
|
|
// continuation, e.g. a bidi continuation.
|
|
|
|
#define NS_FRAME_IS_FLUID_CONTINUATION NS_FRAME_STATE_BIT(2)
|
2007-06-19 22:12:35 -07:00
|
|
|
|
2013-12-11 03:41:51 -08:00
|
|
|
// For nsIAnonymousContentCreator content that's created using ContentInfo.
|
|
|
|
#define NS_FRAME_ANONYMOUSCONTENTCREATOR_CONTENT NS_FRAME_STATE_BIT(3)
|
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
// If this bit is set, then a reference to the frame is being held
|
|
|
|
// elsewhere. The frame may want to send a notification when it is
|
|
|
|
// destroyed to allow these references to be cleared.
|
|
|
|
#define NS_FRAME_EXTERNAL_REFERENCE NS_FRAME_STATE_BIT(4)
|
|
|
|
|
|
|
|
// If this bit is set, this frame or one of its descendants has a
|
|
|
|
// percentage height that depends on an ancestor of this frame.
|
|
|
|
// (Or it did at one point in the past, since we don't necessarily clear
|
|
|
|
// the bit when it's no longer needed; it's an optimization.)
|
|
|
|
#define NS_FRAME_CONTAINS_RELATIVE_HEIGHT NS_FRAME_STATE_BIT(5)
|
|
|
|
|
|
|
|
// If this bit is set, then the frame corresponds to generated content
|
|
|
|
#define NS_FRAME_GENERATED_CONTENT NS_FRAME_STATE_BIT(6)
|
|
|
|
|
|
|
|
// If this bit is set the frame is a continuation that is holding overflow,
|
|
|
|
// i.e. it is a next-in-flow created to hold overflow after the box's
|
|
|
|
// height has ended. This means the frame should be a) at the top of the
|
|
|
|
// page and b) invisible: no borders, zero height, ignored in margin
|
|
|
|
// collapsing, etc. See nsContainerFrame.h
|
|
|
|
#define NS_FRAME_IS_OVERFLOW_CONTAINER NS_FRAME_STATE_BIT(7)
|
|
|
|
|
|
|
|
// If this bit is set, then the frame has been moved out of the flow,
|
|
|
|
// e.g., it is absolutely positioned or floated
|
|
|
|
#define NS_FRAME_OUT_OF_FLOW NS_FRAME_STATE_BIT(8)
|
|
|
|
|
2012-11-01 17:52:59 -07:00
|
|
|
// Frame can be an abs/fixed pos. container, if its style says so.
|
|
|
|
// MarkAs[Not]AbsoluteContainingBlock will assert that this bit is set.
|
|
|
|
// NS_FRAME_HAS_ABSPOS_CHILDREN must not be set when this bit is unset.
|
|
|
|
#define NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN NS_FRAME_STATE_BIT(9)
|
2010-06-26 09:55:05 -07:00
|
|
|
|
2012-08-29 01:01:09 -07:00
|
|
|
// If this bit is set, then the frame and _all_ of its descendant frames need
|
|
|
|
// to be reflowed.
|
2010-06-26 09:55:05 -07:00
|
|
|
// This bit is set when the frame is first created.
|
|
|
|
// This bit is cleared by DidReflow after the required call to Reflow has
|
|
|
|
// finished.
|
|
|
|
// Do not set this bit yourself if you plan to pass the frame to
|
|
|
|
// nsIPresShell::FrameNeedsReflow. Pass the right arguments instead.
|
|
|
|
#define NS_FRAME_IS_DIRTY NS_FRAME_STATE_BIT(10)
|
|
|
|
|
|
|
|
// If this bit is set then the frame is too deep in the frame tree, and
|
|
|
|
// we'll stop updating it and its children, to prevent stack overflow
|
|
|
|
// and the like.
|
|
|
|
#define NS_FRAME_TOO_DEEP_IN_FRAME_TREE NS_FRAME_STATE_BIT(11)
|
|
|
|
|
2012-08-29 01:01:09 -07:00
|
|
|
// If this bit is set, then either:
|
|
|
|
// 1. the frame has at least one child that has the NS_FRAME_IS_DIRTY bit or
|
|
|
|
// NS_FRAME_HAS_DIRTY_CHILDREN bit set, or
|
|
|
|
// 2. the frame has had at least one child removed since the last reflow, or
|
|
|
|
// 3. the frame has had a style change that requires the frame to be reflowed
|
|
|
|
// but does not _necessarily_ require its descendants to be reflowed (e.g.,
|
|
|
|
// for a 'height', 'width', 'margin', etc. change, it's up to the
|
|
|
|
// applicable Reflow methods to decide whether the frame's children
|
|
|
|
// _actually_ need to be reflowed).
|
|
|
|
// If this bit is set but the NS_FRAME_IS_DIRTY is not set, then Reflow still
|
|
|
|
// needs to be called on the frame, but Reflow will likely not do as much work
|
|
|
|
// as it would if NS_FRAME_IS_DIRTY were set. See the comment documenting
|
|
|
|
// nsFrame::Reflow for more.
|
2010-06-26 09:55:05 -07:00
|
|
|
// This bit is cleared by DidReflow after the required call to Reflow has
|
|
|
|
// finished.
|
|
|
|
// Do not set this bit yourself if you plan to pass the frame to
|
|
|
|
// nsIPresShell::FrameNeedsReflow. Pass the right arguments instead.
|
|
|
|
#define NS_FRAME_HAS_DIRTY_CHILDREN NS_FRAME_STATE_BIT(12)
|
|
|
|
|
|
|
|
// If this bit is set, the frame has an associated view
|
|
|
|
#define NS_FRAME_HAS_VIEW NS_FRAME_STATE_BIT(13)
|
|
|
|
|
|
|
|
// If this bit is set, the frame was created from anonymous content.
|
|
|
|
#define NS_FRAME_INDEPENDENT_SELECTION NS_FRAME_STATE_BIT(14)
|
|
|
|
|
|
|
|
// If this bit is set, the frame is "special" (lame term, I know),
|
|
|
|
// which means that it is part of the mangled frame hierarchy that
|
|
|
|
// results when an inline has been split because of a nested block.
|
|
|
|
// See the comments in nsCSSFrameConstructor::ConstructInline for
|
|
|
|
// more details.
|
|
|
|
#define NS_FRAME_IS_SPECIAL NS_FRAME_STATE_BIT(15)
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
// If this bit is set, then transforms (e.g. CSS or SVG transforms) are allowed
|
|
|
|
// to affect the frame, and a transform may currently be in affect. If this bit
|
|
|
|
// is not set, then any transforms on the frame will be ignored.
|
2010-06-26 09:55:05 -07:00
|
|
|
// This is used primarily in GetTransformMatrix to optimize for the
|
|
|
|
// common case.
|
2010-08-13 06:31:31 -07:00
|
|
|
#define NS_FRAME_MAY_BE_TRANSFORMED NS_FRAME_STATE_BIT(16)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
2010-06-26 09:55:05 -07:00
|
|
|
// If this bit is set, the frame itself is a bidi continuation,
|
|
|
|
// or is incomplete (its next sibling is a bidi continuation)
|
|
|
|
#define NS_FRAME_IS_BIDI NS_FRAME_STATE_BIT(17)
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
// If this bit is set the frame has descendant with a view
|
|
|
|
#define NS_FRAME_HAS_CHILD_WITH_VIEW NS_FRAME_STATE_BIT(18)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
// If this bit is set, then reflow may be dispatched from the current
|
|
|
|
// frame instead of the root frame.
|
|
|
|
#define NS_FRAME_REFLOW_ROOT NS_FRAME_STATE_BIT(19)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-10 08:16:17 -07:00
|
|
|
// Bits 20-31 and 60-63 of the frame state are reserved for implementations.
|
|
|
|
#define NS_FRAME_IMPL_RESERVED nsFrameState(0xF0000000FFF00000)
|
2011-12-20 01:15:41 -08:00
|
|
|
#define NS_FRAME_RESERVED ~NS_FRAME_IMPL_RESERVED
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-05 21:59:19 -07:00
|
|
|
// This bit is set on floats whose parent does not contain their
|
|
|
|
// placeholder. This can happen for two reasons: (1) the float was
|
|
|
|
// split, and this piece is the continuation, or (2) the entire float
|
|
|
|
// didn't fit on the page.
|
2012-08-30 18:32:02 -07:00
|
|
|
// Note that this bit is also shared by text frames for
|
2014-01-15 21:10:09 -08:00
|
|
|
// TEXT_IS_IN_TOKEN_MATHML. That's OK because we only check the
|
2012-08-30 18:32:02 -07:00
|
|
|
// NS_FRAME_IS_PUSHED_FLOAT bit on frames which we already know are
|
|
|
|
// out-of-flow.
|
2010-08-05 21:59:20 -07:00
|
|
|
#define NS_FRAME_IS_PUSHED_FLOAT NS_FRAME_STATE_BIT(32)
|
2010-08-05 21:59:19 -07:00
|
|
|
|
2010-08-13 09:09:58 -07:00
|
|
|
// This bit acts as a loop flag for recursive paint server drawing.
|
|
|
|
#define NS_FRAME_DRAWING_AS_PAINTSERVER NS_FRAME_STATE_BIT(33)
|
|
|
|
|
2012-07-03 17:20:24 -07:00
|
|
|
// Frame is a display root and the retained layer tree needs to be updated
|
|
|
|
// at the next paint via display list construction.
|
|
|
|
// Only meaningful for display roots, so we don't really need a global state
|
|
|
|
// bit; we could free up this bit with a little extra complexity.
|
|
|
|
#define NS_FRAME_UPDATE_LAYER_TREE NS_FRAME_STATE_BIT(36)
|
|
|
|
|
2011-04-27 16:41:43 -07:00
|
|
|
// Frame can accept absolutely positioned children.
|
|
|
|
#define NS_FRAME_HAS_ABSPOS_CHILDREN NS_FRAME_STATE_BIT(37)
|
|
|
|
|
2011-10-25 20:23:26 -07:00
|
|
|
// A display item for this frame has been painted as part of a ThebesLayer.
|
|
|
|
#define NS_FRAME_PAINTED_THEBES NS_FRAME_STATE_BIT(38)
|
|
|
|
|
2012-03-23 20:47:43 -07:00
|
|
|
// Frame is or is a descendant of something with a fixed height, unless that
|
|
|
|
// ancestor is a body or html element, and has no closer ancestor that is
|
|
|
|
// overflow:auto or overflow:scroll.
|
2011-11-23 18:48:23 -08:00
|
|
|
#define NS_FRAME_IN_CONSTRAINED_HEIGHT NS_FRAME_STATE_BIT(39)
|
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
// This is only set during painting
|
|
|
|
#define NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO NS_FRAME_STATE_BIT(40)
|
|
|
|
|
2012-01-24 17:21:28 -08:00
|
|
|
// Is this frame a container for font size inflation, i.e., is it a
|
|
|
|
// frame whose width is used to determine the inflation factor for
|
|
|
|
// everything whose nearest ancestor container for this frame?
|
|
|
|
#define NS_FRAME_FONT_INFLATION_CONTAINER NS_FRAME_STATE_BIT(41)
|
|
|
|
|
2012-04-16 15:32:12 -07:00
|
|
|
// Does this frame manage a region in which we do font size inflation,
|
|
|
|
// i.e., roughly, is it an element establishing a new block formatting
|
|
|
|
// context?
|
|
|
|
#define NS_FRAME_FONT_INFLATION_FLOW_ROOT NS_FRAME_STATE_BIT(42)
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
// This bit is set on SVG frames that are laid out using SVG's coordinate
|
|
|
|
// system based layout (as opposed to any of the CSS layout models). Note that
|
|
|
|
// this does not include nsSVGOuterSVGFrame since it takes part is CSS layout.
|
|
|
|
#define NS_FRAME_SVG_LAYOUT NS_FRAME_STATE_BIT(43)
|
|
|
|
|
2012-05-29 20:45:17 -07:00
|
|
|
// Is this frame allowed to have generated (::before/::after) content?
|
|
|
|
#define NS_FRAME_MAY_HAVE_GENERATED_CONTENT NS_FRAME_STATE_BIT(44)
|
|
|
|
|
2012-07-22 20:00:36 -07:00
|
|
|
// This bit is set on frames that create ContainerLayers with component
|
|
|
|
// alpha children. With BasicLayers we avoid creating these, so we mark
|
|
|
|
// the frames for future reference.
|
|
|
|
#define NS_FRAME_NO_COMPONENT_ALPHA NS_FRAME_STATE_BIT(45)
|
|
|
|
|
2013-12-20 08:38:51 -08:00
|
|
|
// The frame is a descendant of SVGTextFrame and is thus used for SVG
|
2012-08-02 04:38:46 -07:00
|
|
|
// text layout.
|
|
|
|
#define NS_FRAME_IS_SVG_TEXT NS_FRAME_STATE_BIT(47)
|
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
// Frame is marked as needing painting
|
|
|
|
#define NS_FRAME_NEEDS_PAINT NS_FRAME_STATE_BIT(48)
|
|
|
|
|
|
|
|
// Frame has a descendant frame that needs painting - This includes
|
|
|
|
// cross-doc children.
|
|
|
|
#define NS_FRAME_DESCENDANT_NEEDS_PAINT NS_FRAME_STATE_BIT(49)
|
|
|
|
|
|
|
|
// Frame is a descendant of a popup
|
|
|
|
#define NS_FRAME_IN_POPUP NS_FRAME_STATE_BIT(50)
|
|
|
|
|
2012-08-28 22:48:43 -07:00
|
|
|
// Frame has only descendant frames that needs painting - This includes
|
|
|
|
// cross-doc children. This guarantees that all descendents have
|
|
|
|
// NS_FRAME_NEEDS_PAINT and NS_FRAME_ALL_DESCENDANTS_NEED_PAINT, or they
|
|
|
|
// have no display items.
|
|
|
|
#define NS_FRAME_ALL_DESCENDANTS_NEED_PAINT NS_FRAME_STATE_BIT(51)
|
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
// Frame is marked as NS_FRAME_NEEDS_PAINT and also has an explicit
|
|
|
|
// rect stored to invalidate.
|
|
|
|
#define NS_FRAME_HAS_INVALID_RECT NS_FRAME_STATE_BIT(52)
|
|
|
|
|
2013-07-12 00:13:07 -07:00
|
|
|
// Frame is not displayed directly due to it being, or being under, an SVG
|
|
|
|
// <defs> element or an SVG resource element (<mask>, <pattern>, etc.)
|
|
|
|
#define NS_FRAME_IS_NONDISPLAY NS_FRAME_STATE_BIT(53)
|
|
|
|
|
2013-09-09 17:08:41 -07:00
|
|
|
// Frame has a LayerActivityProperty property
|
|
|
|
#define NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY NS_FRAME_STATE_BIT(54)
|
|
|
|
|
2014-01-15 06:49:20 -08:00
|
|
|
// Set for all descendants of MathML sub/supscript elements (other than the
|
|
|
|
// base frame) to indicate that the SSTY font feature should be used.
|
|
|
|
#define NS_FRAME_MATHML_SCRIPT_DESCENDANT NS_FRAME_STATE_BIT(58)
|
|
|
|
|
2014-01-15 21:10:09 -08:00
|
|
|
// This state bit is set on token MathML elements if the token represents an
|
|
|
|
// <mi> tag whose inner HTML consists of a single non-whitespace character
|
|
|
|
// to allow special rendering behaviour.
|
|
|
|
#define NS_FRAME_IS_IN_SINGLE_CHAR_MI NS_FRAME_STATE_BIT(59)
|
|
|
|
|
2010-06-26 09:55:05 -07:00
|
|
|
// Box layout bits
|
|
|
|
#define NS_STATE_IS_HORIZONTAL NS_FRAME_STATE_BIT(22)
|
|
|
|
#define NS_STATE_IS_DIRECTION_NORMAL NS_FRAME_STATE_BIT(31)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-06 12:16:51 -07:00
|
|
|
// Helper macros
|
|
|
|
#define NS_SUBTREE_DIRTY(_frame) \
|
|
|
|
(((_frame)->GetStateBits() & \
|
|
|
|
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) != 0)
|
|
|
|
|
2013-08-23 15:20:19 -07:00
|
|
|
/**
|
|
|
|
* Constant used to indicate an unconstrained size.
|
|
|
|
*
|
|
|
|
* @see #Reflow()
|
|
|
|
*/
|
|
|
|
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
|
|
|
|
|
|
|
|
#define NS_INTRINSICSIZE NS_UNCONSTRAINEDSIZE
|
|
|
|
#define NS_AUTOHEIGHT NS_UNCONSTRAINEDSIZE
|
|
|
|
#define NS_AUTOMARGIN NS_UNCONSTRAINEDSIZE
|
|
|
|
#define NS_AUTOOFFSET NS_UNCONSTRAINEDSIZE
|
|
|
|
// NOTE: there are assumptions all over that these have the same value, namely NS_UNCONSTRAINEDSIZE
|
|
|
|
// if any are changed to be a value other than NS_UNCONSTRAINEDSIZE
|
|
|
|
// at least update AdjustComputedHeight/Width and test ad nauseum
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum nsSelectionAmount {
|
2010-12-16 14:17:41 -08:00
|
|
|
eSelectCharacter = 0, // a single Unicode character;
|
|
|
|
// do not use this (prefer Cluster) unless you
|
|
|
|
// are really sure it's what you want
|
|
|
|
eSelectCluster = 1, // a grapheme cluster: this is usually the right
|
|
|
|
// choice for movement or selection by "character"
|
|
|
|
// as perceived by the user
|
|
|
|
eSelectWord = 2,
|
|
|
|
eSelectLine = 3, // previous drawn line in flow.
|
|
|
|
eSelectBeginLine = 4,
|
|
|
|
eSelectEndLine = 5,
|
|
|
|
eSelectNoAmount = 6, // just bounce back current offset.
|
2011-03-20 12:49:06 -07:00
|
|
|
eSelectParagraph = 7, // select a "paragraph"
|
|
|
|
eSelectWordNoSpace = 8 // select a "word" without selecting the following
|
|
|
|
// space, no matter what the default platform
|
|
|
|
// behavior is
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum nsSpread {
|
|
|
|
eSpreadNone = 0,
|
|
|
|
eSpreadAcross = 1,
|
|
|
|
eSpreadDown = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
// Carried out margin flags
|
|
|
|
#define NS_CARRIED_TOP_MARGIN_IS_AUTO 0x1
|
|
|
|
#define NS_CARRIED_BOTTOM_MARGIN_IS_AUTO 0x2
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
2007-07-25 21:03:29 -07:00
|
|
|
* Reflow status returned by the reflow methods. There are three
|
|
|
|
* completion statuses, represented by two bit flags.
|
|
|
|
*
|
|
|
|
* NS_FRAME_COMPLETE means the frame is fully complete.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* NS_FRAME_NOT_COMPLETE bit flag means the frame does not map all its
|
|
|
|
* content, and that the parent frame should create a continuing frame.
|
|
|
|
* If this bit isn't set it means the frame does map all its content.
|
2007-07-25 21:03:29 -07:00
|
|
|
* This bit is mutually exclusive with NS_FRAME_OVERFLOW_INCOMPLETE.
|
|
|
|
*
|
|
|
|
* NS_FRAME_OVERFLOW_INCOMPLETE bit flag means that the frame has
|
|
|
|
* overflow that is not complete, but its own box is complete.
|
|
|
|
* (This happens when content overflows a fixed-height box.)
|
|
|
|
* The reflower should place and size the frame and continue its reflow,
|
|
|
|
* but needs to create an overflow container as a continuation for this
|
|
|
|
* frame. See nsContainerFrame.h for more information.
|
|
|
|
* This bit is mutually exclusive with NS_FRAME_NOT_COMPLETE.
|
|
|
|
*
|
2008-05-28 06:39:41 -07:00
|
|
|
* Please use the SET macro for handling
|
2007-07-25 21:03:29 -07:00
|
|
|
* NS_FRAME_NOT_COMPLETE and NS_FRAME_OVERFLOW_INCOMPLETE.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* NS_FRAME_REFLOW_NEXTINFLOW bit flag means that the next-in-flow is
|
|
|
|
* dirty, and also needs to be reflowed. This status only makes sense
|
|
|
|
* for a frame that is not complete, i.e. you wouldn't set both
|
2007-07-25 21:03:29 -07:00
|
|
|
* NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* The low 8 bits of the nsReflowStatus are reserved for future extensions;
|
|
|
|
* the remaining 24 bits are zero (and available for extensions; however
|
|
|
|
* API's that accept/return nsReflowStatus must not receive/return any
|
|
|
|
* extension bits).
|
|
|
|
*
|
|
|
|
* @see #Reflow()
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef uint32_t nsReflowStatus;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
#define NS_FRAME_COMPLETE 0 // Note: not a bit!
|
|
|
|
#define NS_FRAME_NOT_COMPLETE 0x1
|
|
|
|
#define NS_FRAME_REFLOW_NEXTINFLOW 0x2
|
|
|
|
#define NS_FRAME_OVERFLOW_INCOMPLETE 0x4
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_FRAME_IS_COMPLETE(status) \
|
|
|
|
(0 == ((status) & NS_FRAME_NOT_COMPLETE))
|
|
|
|
|
|
|
|
#define NS_FRAME_IS_NOT_COMPLETE(status) \
|
|
|
|
(0 != ((status) & NS_FRAME_NOT_COMPLETE))
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
#define NS_FRAME_OVERFLOW_IS_INCOMPLETE(status) \
|
|
|
|
(0 != ((status) & NS_FRAME_OVERFLOW_INCOMPLETE))
|
|
|
|
|
|
|
|
#define NS_FRAME_IS_FULLY_COMPLETE(status) \
|
|
|
|
(NS_FRAME_IS_COMPLETE(status) && !NS_FRAME_OVERFLOW_IS_INCOMPLETE(status))
|
|
|
|
|
2013-09-10 16:41:04 -07:00
|
|
|
// These macros set or switch incomplete statuses without touching the
|
2007-07-25 21:03:29 -07:00
|
|
|
// NS_FRAME_REFLOW_NEXTINFLOW bit.
|
|
|
|
#define NS_FRAME_SET_INCOMPLETE(status) \
|
2008-09-15 08:40:25 -07:00
|
|
|
status = (status & ~NS_FRAME_OVERFLOW_INCOMPLETE) | NS_FRAME_NOT_COMPLETE
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
#define NS_FRAME_SET_OVERFLOW_INCOMPLETE(status) \
|
2008-09-15 08:40:25 -07:00
|
|
|
status = (status & ~NS_FRAME_NOT_COMPLETE) | NS_FRAME_OVERFLOW_INCOMPLETE
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// This macro tests to see if an nsReflowStatus is an error value
|
|
|
|
// or just a regular return value
|
2012-08-22 08:56:38 -07:00
|
|
|
#define NS_IS_REFLOW_ERROR(_status) (int32_t(_status) < 0)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extensions to the reflow status bits defined by nsIFrameReflow
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This bit is set, when a break is requested. This bit is orthogonal
|
|
|
|
// to the nsIFrame::nsReflowStatus completion bits.
|
|
|
|
#define NS_INLINE_BREAK 0x0100
|
|
|
|
|
|
|
|
// When a break is requested, this bit when set indicates that the
|
|
|
|
// break should occur after the frame just reflowed; when the bit is
|
|
|
|
// clear the break should occur before the frame just reflowed.
|
|
|
|
#define NS_INLINE_BREAK_BEFORE 0x0000
|
|
|
|
#define NS_INLINE_BREAK_AFTER 0x0200
|
|
|
|
|
|
|
|
// The type of break requested can be found in these bits.
|
|
|
|
#define NS_INLINE_BREAK_TYPE_MASK 0xF000
|
|
|
|
|
2008-08-05 17:31:25 -07:00
|
|
|
// Set when a break was induced by completion of a first-letter
|
|
|
|
#define NS_INLINE_BREAK_FIRST_LETTER_COMPLETE 0x10000
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------
|
|
|
|
// Macros that use those bits
|
|
|
|
|
|
|
|
#define NS_INLINE_IS_BREAK(_status) \
|
|
|
|
(0 != ((_status) & NS_INLINE_BREAK))
|
|
|
|
|
|
|
|
#define NS_INLINE_IS_BREAK_AFTER(_status) \
|
|
|
|
(0 != ((_status) & NS_INLINE_BREAK_AFTER))
|
|
|
|
|
|
|
|
#define NS_INLINE_IS_BREAK_BEFORE(_status) \
|
|
|
|
(NS_INLINE_BREAK == ((_status) & (NS_INLINE_BREAK|NS_INLINE_BREAK_AFTER)))
|
|
|
|
|
|
|
|
#define NS_INLINE_GET_BREAK_TYPE(_status) (((_status) >> 12) & 0xF)
|
|
|
|
|
|
|
|
#define NS_INLINE_MAKE_BREAK_TYPE(_type) ((_type) << 12)
|
|
|
|
|
|
|
|
// Construct a line-break-before status. Note that there is no
|
|
|
|
// completion status for a line-break before because we *know* that
|
2013-09-12 11:28:46 -07:00
|
|
|
// the frame will be reflowed later and hence its current completion
|
2007-03-22 10:30:00 -07:00
|
|
|
// status doesn't matter.
|
|
|
|
#define NS_INLINE_LINE_BREAK_BEFORE() \
|
|
|
|
(NS_INLINE_BREAK | NS_INLINE_BREAK_BEFORE | \
|
|
|
|
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
|
|
|
|
|
|
|
// Take a completion status and add to it the desire to have a
|
|
|
|
// line-break after. For this macro we do need the completion status
|
|
|
|
// because the user of the status will need to know whether to
|
|
|
|
// continue the frame or not.
|
|
|
|
#define NS_INLINE_LINE_BREAK_AFTER(_completionStatus) \
|
|
|
|
((_completionStatus) | NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER | \
|
|
|
|
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
|
|
|
|
2010-08-05 21:59:19 -07:00
|
|
|
// A frame is "truncated" if the part of the frame before the first
|
|
|
|
// possible break point was unable to fit in the available vertical
|
|
|
|
// space. Therefore, the entire frame should be moved to the next page.
|
|
|
|
// A frame that begins at the top of the page must never be "truncated".
|
|
|
|
// Doing so would likely cause an infinite loop.
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_FRAME_TRUNCATED 0x0010
|
|
|
|
#define NS_FRAME_IS_TRUNCATED(status) \
|
|
|
|
(0 != ((status) & NS_FRAME_TRUNCATED))
|
|
|
|
#define NS_FRAME_SET_TRUNCATION(status, aReflowState, aMetrics) \
|
|
|
|
aReflowState.SetTruncated(aMetrics, &status);
|
|
|
|
|
2008-05-28 06:39:41 -07:00
|
|
|
// Merge the incompleteness, truncation and NS_FRAME_REFLOW_NEXTINFLOW
|
|
|
|
// status from aSecondary into aPrimary.
|
|
|
|
void NS_MergeReflowStatusInto(nsReflowStatus* aPrimary,
|
|
|
|
nsReflowStatus aSecondary);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DidReflow status values.
|
|
|
|
*/
|
2012-11-13 22:47:33 -08:00
|
|
|
MOZ_BEGIN_ENUM_CLASS(nsDidReflowStatus, uint32_t)
|
|
|
|
NOT_FINISHED,
|
|
|
|
FINISHED
|
|
|
|
MOZ_END_ENUM_CLASS(nsDidReflowStatus)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-05 17:31:50 -07:00
|
|
|
/**
|
2010-10-06 21:25:45 -07:00
|
|
|
* When there is no scrollable overflow rect, the visual overflow rect
|
|
|
|
* may be stored as four 1-byte deltas each strictly LESS THAN 0xff, for
|
|
|
|
* the four edges of the rectangle, or the four bytes may be read as a
|
|
|
|
* single 32-bit "overflow-rect type" value including at least one 0xff
|
|
|
|
* byte as an indicator that the value does NOT represent four deltas.
|
2009-04-05 17:31:50 -07:00
|
|
|
* If all four deltas are zero, this means that no overflow rect has
|
|
|
|
* actually been set (this is the initial state of newly-created frames).
|
|
|
|
*/
|
|
|
|
#define NS_FRAME_OVERFLOW_DELTA_MAX 0xfe // max delta we can store
|
|
|
|
|
2010-10-06 21:25:45 -07:00
|
|
|
#define NS_FRAME_OVERFLOW_NONE 0x00000000 // there are no overflow rects;
|
2009-04-05 17:31:50 -07:00
|
|
|
// code relies on this being
|
|
|
|
// the all-zero value
|
|
|
|
|
|
|
|
#define NS_FRAME_OVERFLOW_LARGE 0x000000ff // overflow is stored as a
|
|
|
|
// separate rect property
|
|
|
|
|
2013-09-30 14:26:04 -07:00
|
|
|
namespace mozilla {
|
|
|
|
/*
|
|
|
|
* For replaced elements only. Gets the intrinsic dimensions of this element.
|
|
|
|
* The dimensions may only be one of the following two types:
|
|
|
|
*
|
|
|
|
* eStyleUnit_Coord - a length in app units
|
|
|
|
* eStyleUnit_None - the element has no intrinsic size in this dimension
|
|
|
|
*/
|
|
|
|
struct IntrinsicSize {
|
|
|
|
nsStyleCoord width, height;
|
|
|
|
|
|
|
|
IntrinsicSize()
|
|
|
|
: width(eStyleUnit_None), height(eStyleUnit_None)
|
|
|
|
{}
|
|
|
|
IntrinsicSize(const IntrinsicSize& rhs)
|
|
|
|
: width(rhs.width), height(rhs.height)
|
|
|
|
{}
|
|
|
|
IntrinsicSize& operator=(const IntrinsicSize& rhs) {
|
|
|
|
width = rhs.width; height = rhs.height; return *this;
|
|
|
|
}
|
|
|
|
bool operator==(const IntrinsicSize& rhs) {
|
|
|
|
return width == rhs.width && height == rhs.height;
|
|
|
|
}
|
|
|
|
bool operator!=(const IntrinsicSize& rhs) {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A frame in the layout model. This interface is supported by all frame
|
|
|
|
* objects.
|
|
|
|
*
|
2011-08-24 13:54:30 -07:00
|
|
|
* Frames can have multiple child lists: the default child list
|
2007-03-22 10:30:00 -07:00
|
|
|
* (referred to as the <i>principal</i> child list, and additional named
|
|
|
|
* child lists. There is an ordering of frames within a child list, but
|
|
|
|
* there is no order defined between frames in different child lists of
|
|
|
|
* the same parent frame.
|
|
|
|
*
|
|
|
|
* Frames are NOT reference counted. Use the Destroy() member function
|
|
|
|
* to destroy a frame. The lifetime of the frame hierarchy is bounded by the
|
|
|
|
* lifetime of the presentation shell which owns the frames.
|
|
|
|
*
|
|
|
|
* nsIFrame is a private Gecko interface. If you are not Gecko then you
|
|
|
|
* should not use it. If you're not in layout, then you won't be able to
|
|
|
|
* link to many of the functions defined here. Too bad.
|
|
|
|
*
|
|
|
|
* If you're not in layout but you must call functions in here, at least
|
|
|
|
* restrict yourself to calling virtual methods, which won't hurt you as badly.
|
|
|
|
*/
|
2009-01-12 11:20:59 -08:00
|
|
|
class nsIFrame : public nsQueryFrame
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-03-28 18:46:55 -07:00
|
|
|
typedef mozilla::FramePropertyDescriptor FramePropertyDescriptor;
|
|
|
|
typedef mozilla::FrameProperties FrameProperties;
|
2011-03-27 16:59:47 -07:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
2011-08-24 13:54:29 -07:00
|
|
|
typedef mozilla::layout::FrameChildList ChildList;
|
|
|
|
typedef mozilla::layout::FrameChildListID ChildListID;
|
|
|
|
typedef mozilla::layout::FrameChildListIDs ChildListIDs;
|
|
|
|
typedef mozilla::layout::FrameChildListIterator ChildListIterator;
|
|
|
|
typedef mozilla::layout::FrameChildListArrayIterator ChildListArrayIterator;
|
2013-12-29 22:50:07 -08:00
|
|
|
typedef mozilla::gfx::Matrix Matrix;
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsIFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* PresContext() const {
|
2013-02-16 13:04:54 -08:00
|
|
|
return StyleContext()->RuleNode()->PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to initialize the frame. This is called immediately after creating
|
|
|
|
* the frame.
|
|
|
|
*
|
|
|
|
* If the frame is a continuing frame, then aPrevInFlow indicates the previous
|
2007-07-20 12:00:36 -07:00
|
|
|
* frame (the frame that was split).
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* If you want a view associated with your frame, you should create the view
|
2013-03-19 18:47:48 -07:00
|
|
|
* after Init() has returned.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @param aContent the content object associated with the frame
|
2013-03-19 18:47:48 -07:00
|
|
|
* @param aParent the parent frame
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aPrevInFlow the prev-in-flow frame
|
|
|
|
*/
|
2013-03-19 18:47:48 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys this frame and each of its child frames (recursively calls
|
2009-12-23 21:20:41 -08:00
|
|
|
* Destroy() for each child). If this frame is a first-continuation, this
|
2011-09-07 17:19:32 -07:00
|
|
|
* also removes the frame from the primary frame map and clears undisplayed
|
2009-12-23 21:20:41 -08:00
|
|
|
* content for its content node.
|
|
|
|
* If the frame is a placeholder, it also ensures the out-of-flow frame's
|
|
|
|
* removal and destruction.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-12-23 21:21:15 -08:00
|
|
|
void Destroy() { DestroyFrom(this); }
|
|
|
|
|
|
|
|
protected:
|
2011-12-20 01:15:41 -08:00
|
|
|
/**
|
|
|
|
* Return true if the frame is part of a Selection.
|
|
|
|
* Helper method to implement the public IsSelected() API.
|
|
|
|
*/
|
|
|
|
virtual bool IsFrameSelected() const;
|
|
|
|
|
2009-12-23 21:21:15 -08:00
|
|
|
/**
|
|
|
|
* Implements Destroy(). Do not call this directly except from within a
|
|
|
|
* DestroyFrom() implementation.
|
2011-11-09 13:39:16 -08:00
|
|
|
*
|
|
|
|
* @note This will always be called, so it is not necessary to override
|
|
|
|
* Destroy() in subclasses of nsFrame, just DestroyFrom().
|
|
|
|
*
|
2009-12-23 21:21:15 -08:00
|
|
|
* @param aDestructRoot is the root of the subtree being destroyed
|
|
|
|
*/
|
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) = 0;
|
|
|
|
friend class nsFrameList; // needed to pass aDestructRoot through to children
|
|
|
|
friend class nsLineBox; // needed to pass aDestructRoot through to children
|
2013-02-10 18:28:50 -08:00
|
|
|
friend class nsContainerFrame; // needed to pass aDestructRoot through to children
|
2009-12-23 21:21:15 -08:00
|
|
|
public:
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to set the initial list of frames. This happens after the frame
|
|
|
|
* has been initialized.
|
|
|
|
*
|
|
|
|
* This is only called once for a given child list, and won't be called
|
|
|
|
* at all for child lists with no initial list of frames.
|
|
|
|
*
|
2011-08-24 13:54:30 -07:00
|
|
|
* @param aListID the child list identifier.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aChildList list of child frames. Each of the frames has its
|
2009-07-30 10:23:32 -07:00
|
|
|
* NS_FRAME_IS_DIRTY bit set. Must not be empty.
|
2011-04-29 16:02:33 -07:00
|
|
|
* This method cannot handle the child list returned by
|
|
|
|
* GetAbsoluteListID().
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
|
|
|
|
* name,
|
|
|
|
* NS_ERROR_UNEXPECTED if the frame is an atomic frame or if the
|
|
|
|
* initial list of frames has already been set for that child list,
|
2009-07-28 05:53:20 -07:00
|
|
|
* NS_OK otherwise. In this case, SetInitialChildList empties out
|
|
|
|
* aChildList in the process of moving the frames over to its own
|
|
|
|
* child list.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @see #Init()
|
|
|
|
*/
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD SetInitialChildList(ChildListID aListID,
|
2009-07-28 05:53:20 -07:00
|
|
|
nsFrameList& aChildList) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is responsible for appending frames to the frame
|
|
|
|
* list. The implementation should append the frames to the specified
|
|
|
|
* child list and then generate a reflow command.
|
|
|
|
*
|
2011-08-24 13:54:30 -07:00
|
|
|
* @param aListID the child list identifier.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aFrameList list of child frames to append. Each of the frames has
|
2009-07-30 10:23:32 -07:00
|
|
|
* its NS_FRAME_IS_DIRTY bit set. Must not be empty.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
|
|
|
|
* name,
|
|
|
|
* NS_ERROR_UNEXPECTED if the frame is an atomic frame,
|
2009-07-30 10:23:32 -07:00
|
|
|
* NS_OK otherwise. In this case, AppendFrames empties out
|
2012-07-15 13:21:00 -07:00
|
|
|
* aFrameList in the process of moving the frames over to its own
|
2009-07-30 10:23:32 -07:00
|
|
|
* child list.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD AppendFrames(ChildListID aListID,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is responsible for inserting frames into the frame
|
|
|
|
* list. The implementation should insert the new frames into the specified
|
|
|
|
* child list and then generate a reflow command.
|
|
|
|
*
|
2011-08-24 13:54:30 -07:00
|
|
|
* @param aListID the child list identifier.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aPrevFrame the frame to insert frames <b>after</b>
|
|
|
|
* @param aFrameList list of child frames to insert <b>after</b> aPrevFrame.
|
|
|
|
* Each of the frames has its NS_FRAME_IS_DIRTY bit set
|
|
|
|
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
|
|
|
|
* name,
|
|
|
|
* NS_ERROR_UNEXPECTED if the frame is an atomic frame,
|
2009-07-30 10:23:32 -07:00
|
|
|
* NS_OK otherwise. In this case, InsertFrames empties out
|
2012-07-15 13:21:00 -07:00
|
|
|
* aFrameList in the process of moving the frames over to its own
|
2009-07-30 10:23:32 -07:00
|
|
|
* child list.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is responsible for removing a frame in the frame
|
|
|
|
* list. The implementation should do something with the removed frame
|
|
|
|
* and then generate a reflow command. The implementation is responsible
|
|
|
|
* for destroying aOldFrame (the caller mustn't destroy aOldFrame).
|
|
|
|
*
|
2011-08-24 13:54:30 -07:00
|
|
|
* @param aListID the child list identifier.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aOldFrame the frame to remove
|
|
|
|
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
|
|
|
|
* name,
|
|
|
|
* NS_ERROR_FAILURE if the child frame is not in the specified
|
|
|
|
* child list,
|
|
|
|
* NS_ERROR_UNEXPECTED if the frame is an atomic frame,
|
|
|
|
* NS_OK otherwise
|
|
|
|
*/
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD RemoveFrame(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aOldFrame) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the content object associated with this frame. Does not add a reference.
|
|
|
|
*/
|
|
|
|
nsIContent* GetContent() const { return mContent; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the frame that should be the parent for the frames of child elements
|
2012-07-30 07:20:58 -07:00
|
|
|
* May return nullptr during reflow
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
virtual nsIFrame* GetContentInsertionFrame() { return this; }
|
|
|
|
|
2012-09-17 16:05:05 -07:00
|
|
|
/**
|
|
|
|
* Move any frames on our overflow list to the end of our principal list.
|
|
|
|
* @return true if there were any overflow frames
|
|
|
|
*/
|
|
|
|
virtual bool DrainSelfOverflowList() { return false; }
|
|
|
|
|
2009-09-01 04:22:31 -07:00
|
|
|
/**
|
|
|
|
* Get the frame that should be scrolled if the content associated
|
|
|
|
* with this frame is targeted for scrolling. For frames implementing
|
|
|
|
* nsIScrollableFrame this will return the frame itself. For frames
|
|
|
|
* like nsTextControlFrame that contain a scrollframe, will return
|
|
|
|
* that scrollframe.
|
|
|
|
*/
|
2012-07-30 07:20:58 -07:00
|
|
|
virtual nsIScrollableFrame* GetScrollTargetFrame() { return nullptr; }
|
2009-09-01 04:22:31 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the offsets of the frame. most will be 0,0
|
|
|
|
*
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetOffsets(int32_t &start, int32_t &end) const = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the offsets when splitting frames during Bidi reordering
|
|
|
|
*
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void AdjustOffsetsForBidi(int32_t aStart, int32_t aEnd) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the style context associated with this frame.
|
|
|
|
*/
|
2013-02-15 21:38:33 -08:00
|
|
|
nsStyleContext* StyleContext() const { return mStyleContext; }
|
2007-03-22 10:30:00 -07:00
|
|
|
void SetStyleContext(nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
if (aContext != mStyleContext) {
|
2008-10-26 03:11:34 -07:00
|
|
|
nsStyleContext* oldStyleContext = mStyleContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
mStyleContext = aContext;
|
2013-08-02 21:11:05 -07:00
|
|
|
aContext->AddRef();
|
|
|
|
DidSetStyleContext(oldStyleContext);
|
|
|
|
oldStyleContext->Release();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2013-07-30 17:36:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SetStyleContextWithoutNotification is for changes to the style
|
|
|
|
* context that should suppress style change processing, in other
|
|
|
|
* words, those that aren't really changes. This generally means only
|
|
|
|
* changes that happen during frame construction.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
void SetStyleContextWithoutNotification(nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
if (aContext != mStyleContext) {
|
2013-08-02 21:11:05 -07:00
|
|
|
mStyleContext->Release();
|
2007-03-22 10:30:00 -07:00
|
|
|
mStyleContext = aContext;
|
2013-08-02 21:11:05 -07:00
|
|
|
aContext->AddRef();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Style post processing hook
|
2008-10-26 03:11:34 -07:00
|
|
|
// Attention: the old style context is the one we're forgetting,
|
|
|
|
// and hence possibly completely bogus for GetStyle* purposes.
|
|
|
|
// Use PeekStyleData instead.
|
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Define typesafe getter functions for each style struct by
|
|
|
|
* preprocessing the list of style structs. These functions are the
|
|
|
|
* preferred way to get style data. The macro creates functions like:
|
2013-02-16 13:51:02 -08:00
|
|
|
* const nsStyleBorder* StyleBorder();
|
|
|
|
* const nsStyleColor* StyleColor();
|
2013-05-24 09:21:53 -07:00
|
|
|
*
|
|
|
|
* Callers outside of libxul should use nsIDOMWindow::GetComputedStyle()
|
|
|
|
* instead of these accessors.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-04-01 18:45:48 -07:00
|
|
|
#define STYLE_STRUCT(name_, checkdata_cb_) \
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyle##name_ * Style##name_ () const { \
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(mStyleContext, "No style context found!"); \
|
2013-02-16 13:51:02 -08:00
|
|
|
return mStyleContext->Style##name_ (); \
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
2010-04-02 18:58:25 -07:00
|
|
|
/** Also forward GetVisitedDependentColor to the style context */
|
|
|
|
nscolor GetVisitedDependentColor(nsCSSProperty aProperty)
|
|
|
|
{ return mStyleContext->GetVisitedDependentColor(aProperty); }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* These methods are to access any additional style contexts that
|
|
|
|
* the frame may be holding. These are contexts that are children
|
|
|
|
* of the frame's primary context and are NOT used as style contexts
|
|
|
|
* for any child frames. These contexts also MUST NOT have any child
|
|
|
|
* contexts whatsoever. If you need to insert style contexts into the
|
|
|
|
* style tree, then you should create pseudo element frames to own them
|
|
|
|
* The indicies must be consecutive and implementations MUST return an
|
|
|
|
* NS_ERROR_INVALID_ARG if asked for an index that is out of range.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void SetAdditionalStyleContext(int32_t aIndex,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleContext* aStyleContext) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessor functions for geometric parent
|
|
|
|
*/
|
|
|
|
nsIFrame* GetParent() const { return mParent; }
|
2013-11-23 01:48:26 -08:00
|
|
|
/**
|
|
|
|
* Set this frame's parent to aParent.
|
|
|
|
* If the frame may have moved into or out of a scrollframe's
|
|
|
|
* frame subtree, StickyScrollContainer::NotifyReparentedFrameAcrossScrollFrameBoundary
|
|
|
|
* must also be called.
|
|
|
|
*/
|
2010-08-30 17:46:26 -07:00
|
|
|
virtual void SetParent(nsIFrame* aParent) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-12-27 09:58:46 -08:00
|
|
|
/**
|
|
|
|
* The frame's writing-mode, used for logical layout computations.
|
|
|
|
*/
|
|
|
|
mozilla::WritingMode GetWritingMode() const {
|
|
|
|
return mozilla::WritingMode(StyleVisibility());
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2008-11-19 20:42:55 -08:00
|
|
|
* Bounding rect of the frame. The values are in app units, and the origin is
|
2007-03-22 10:30:00 -07:00
|
|
|
* relative to the upper-left of the geometric parent. The size includes the
|
|
|
|
* content area, borders, and padding.
|
|
|
|
*
|
|
|
|
* Note: moving or sizing the frame does not affect the view's size or
|
|
|
|
* position.
|
|
|
|
*/
|
|
|
|
nsRect GetRect() const { return mRect; }
|
2013-08-14 05:27:20 -07:00
|
|
|
nsPoint GetPosition() const { return mRect.TopLeft(); }
|
|
|
|
nsSize GetSize() const { return mRect.Size(); }
|
2013-12-03 11:13:16 -08:00
|
|
|
nsRect GetRectRelativeToSelf() const {
|
|
|
|
return nsRect(nsPoint(0, 0), mRect.Size());
|
|
|
|
}
|
2009-04-05 17:31:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When we change the size of the frame's border-box rect, we may need to
|
|
|
|
* reset the overflow rect if it was previously stored as deltas.
|
|
|
|
* (If it is currently a "large" overflow and could be re-packed as deltas,
|
|
|
|
* we don't bother as the cost of the allocation has already been paid.)
|
|
|
|
*/
|
|
|
|
void SetRect(const nsRect& aRect) {
|
2010-10-06 21:25:45 -07:00
|
|
|
if (mOverflow.mType != NS_FRAME_OVERFLOW_LARGE &&
|
|
|
|
mOverflow.mType != NS_FRAME_OVERFLOW_NONE) {
|
|
|
|
nsOverflowAreas overflow = GetOverflowAreas();
|
2009-04-05 17:31:50 -07:00
|
|
|
mRect = aRect;
|
2010-10-06 21:25:45 -07:00
|
|
|
SetOverflowAreas(overflow);
|
2009-04-05 17:31:50 -07:00
|
|
|
} else {
|
|
|
|
mRect = aRect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void SetSize(const nsSize& aSize) {
|
2010-10-06 21:25:45 -07:00
|
|
|
SetRect(nsRect(mRect.TopLeft(), aSize));
|
2009-04-05 17:31:50 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
void SetPosition(const nsPoint& aPt) { mRect.MoveTo(aPt); }
|
|
|
|
|
2013-09-11 11:51:42 -07:00
|
|
|
/**
|
|
|
|
* Move the frame, accounting for relative positioning. Use this when
|
|
|
|
* adjusting the frame's position by a known amount, to properly update its
|
|
|
|
* saved normal position (see GetNormalPosition below).
|
2013-09-17 04:44:16 -07:00
|
|
|
*
|
|
|
|
* This must be used only when moving a frame *after*
|
|
|
|
* nsHTMLReflowState::ApplyRelativePositioning is called. When moving
|
|
|
|
* a frame during the reflow process prior to calling
|
|
|
|
* nsHTMLReflowState::ApplyRelativePositioning, the position should
|
|
|
|
* simply be adjusted directly (e.g., using SetPosition()).
|
2013-09-11 11:51:42 -07:00
|
|
|
*/
|
|
|
|
void MovePositionBy(const nsPoint& aTranslation);
|
|
|
|
|
2008-04-18 00:40:35 -07:00
|
|
|
/**
|
2013-08-08 17:20:17 -07:00
|
|
|
* Return frame's position without relative positioning
|
2008-04-18 00:40:35 -07:00
|
|
|
*/
|
2013-08-08 17:20:17 -07:00
|
|
|
nsPoint GetNormalPosition() const;
|
2008-04-18 00:40:35 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild)
|
|
|
|
{ return aChild->GetPosition(); }
|
|
|
|
|
|
|
|
nsPoint GetPositionIgnoringScrolling() {
|
|
|
|
return mParent ? mParent->GetPositionOfChildIgnoringScrolling(this)
|
|
|
|
: GetPosition();
|
|
|
|
}
|
|
|
|
|
2013-08-23 15:16:38 -07:00
|
|
|
static void DestroyRegion(void* aPropertyValue);
|
2010-07-15 14:07:50 -07:00
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
static void DestroyMargin(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<nsMargin*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DestroyRect(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<nsRect*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DestroyPoint(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<nsPoint*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
2010-10-06 21:25:45 -07:00
|
|
|
static void DestroyOverflowAreas(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<nsOverflowAreas*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
2013-08-23 15:16:16 -07:00
|
|
|
static void DestroySurface(void* aPropertyValue);
|
2013-10-02 02:12:34 -07:00
|
|
|
static void DestroyDT(void* aPropertyValue);
|
2012-07-22 20:00:36 -07:00
|
|
|
|
2010-04-03 13:21:53 -07:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
// XXX Workaround MSVC issue by making the static FramePropertyDescriptor
|
|
|
|
// non-const. See bug 555727.
|
2010-07-15 14:07:45 -07:00
|
|
|
#define NS_PROPERTY_DESCRIPTOR_CONST
|
2010-04-03 13:21:53 -07:00
|
|
|
#else
|
2010-07-15 14:07:45 -07:00
|
|
|
#define NS_PROPERTY_DESCRIPTOR_CONST const
|
2010-04-03 13:21:53 -07:00
|
|
|
#endif
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2010-07-15 14:07:45 -07:00
|
|
|
#define NS_DECLARE_FRAME_PROPERTY(prop, dtor) \
|
|
|
|
static const FramePropertyDescriptor* prop() { \
|
2012-07-30 07:20:58 -07:00
|
|
|
static NS_PROPERTY_DESCRIPTOR_CONST FramePropertyDescriptor descriptor = { dtor, nullptr }; \
|
2010-07-15 14:07:45 -07:00
|
|
|
return &descriptor; \
|
|
|
|
}
|
|
|
|
// Don't use this unless you really know what you're doing!
|
|
|
|
#define NS_DECLARE_FRAME_PROPERTY_WITH_FRAME_IN_DTOR(prop, dtor) \
|
|
|
|
static const FramePropertyDescriptor* prop() { \
|
2012-07-30 07:20:58 -07:00
|
|
|
static NS_PROPERTY_DESCRIPTOR_CONST FramePropertyDescriptor descriptor = { nullptr, dtor }; \
|
2010-07-15 14:07:45 -07:00
|
|
|
return &descriptor; \
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(IBSplitSpecialSibling, nullptr)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(IBSplitSpecialPrevSibling, nullptr)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2013-08-08 17:20:17 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(NormalPositionProperty, DestroyPoint)
|
2013-09-10 11:33:59 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(ComputedOffsetProperty, DestroyMargin)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(OutlineInnerRectProperty, DestroyRect)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(PreEffectsBBoxProperty, DestroyRect)
|
2011-06-15 14:03:49 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(PreTransformOverflowAreasProperty,
|
|
|
|
DestroyOverflowAreas)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2011-10-14 13:43:38 -07:00
|
|
|
// The initial overflow area passed to FinishAndStoreOverflow. This is only set
|
|
|
|
// on frames that Preserve3D(), and when at least one of the overflow areas
|
|
|
|
// differs from the frame bound rect.
|
2012-07-08 18:09:50 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(InitialOverflowProperty, DestroyOverflowAreas)
|
2011-10-14 13:43:38 -07:00
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(UsedMarginProperty, DestroyMargin)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(UsedPaddingProperty, DestroyMargin)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(UsedBorderProperty, DestroyMargin)
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(ScrollLayerCount, nullptr)
|
2011-05-01 18:53:01 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(LineBaselineOffset, nullptr)
|
2011-08-03 11:30:58 -07:00
|
|
|
|
2012-07-22 20:00:36 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, DestroySurface)
|
2013-10-02 02:12:34 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT, DestroyDT)
|
2012-07-22 20:00:36 -07:00
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(InvalidationRect, DestroyRect)
|
|
|
|
|
2013-10-22 03:30:45 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(RefusedAsyncAnimation, nullptr)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Return the distance between the border edge of the frame and the
|
2010-03-01 17:57:43 -08:00
|
|
|
* margin edge of the frame. Like GetRect(), returns the dimensions
|
|
|
|
* as of the most recent reflow.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* This doesn't include any margin collapsing that may have occurred.
|
2008-02-26 18:02:50 -08:00
|
|
|
*
|
|
|
|
* It also treats 'auto' margins as zero, and treats any margins that
|
|
|
|
* should have been turned into 'auto' because of overconstraint as
|
|
|
|
* having their original values.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
virtual nsMargin GetUsedMargin() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the distance between the border edge of the frame (which is
|
2010-03-01 17:57:43 -08:00
|
|
|
* its rect) and the padding edge of the frame. Like GetRect(), returns
|
|
|
|
* the dimensions as of the most recent reflow.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2013-02-16 13:51:02 -08:00
|
|
|
* Note that this differs from StyleBorder()->GetBorder() in that
|
2007-03-22 10:30:00 -07:00
|
|
|
* this describes region of the frame's box, and
|
2013-02-16 13:51:02 -08:00
|
|
|
* StyleBorder()->GetBorder() describes a border. They differ only
|
2007-03-22 10:30:00 -07:00
|
|
|
* for tables, particularly border-collapse tables.
|
|
|
|
*/
|
|
|
|
virtual nsMargin GetUsedBorder() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the distance between the padding edge of the frame and the
|
2010-03-01 17:57:43 -08:00
|
|
|
* content edge of the frame. Like GetRect(), returns the dimensions
|
|
|
|
* as of the most recent reflow.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
virtual nsMargin GetUsedPadding() const;
|
|
|
|
|
|
|
|
nsMargin GetUsedBorderAndPadding() const {
|
|
|
|
return GetUsedBorder() + GetUsedPadding();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply the result of GetSkipSides() on this frame to an nsMargin by
|
|
|
|
* setting to zero any sides that are skipped.
|
2013-07-25 08:34:27 -07:00
|
|
|
*
|
|
|
|
* @param aMargin The margin to apply the result of GetSkipSides() to.
|
|
|
|
* @param aReflowState An optional reflow state parameter, which is used if
|
|
|
|
* ApplySkipSides() is being called in the middle of reflow.
|
|
|
|
*
|
2013-09-12 11:28:46 -07:00
|
|
|
* @note (See also bug 743402, comment 11) GetSkipSides() and its sister
|
2013-07-25 08:34:27 -07:00
|
|
|
* method, ApplySkipSides() checks to see if this frame has a previous
|
|
|
|
* or next continuation to determine if a side should be skipped.
|
|
|
|
* Unfortunately, this only works after reflow has been completed. In
|
|
|
|
* lieu of this, during reflow, an nsHTMLReflowState parameter can be
|
|
|
|
* passed in, indicating that it should be used to determine if sides
|
|
|
|
* should be skipped during reflow.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-07-25 08:34:27 -07:00
|
|
|
void ApplySkipSides(nsMargin& aMargin,
|
|
|
|
const nsHTMLReflowState* aReflowState = nullptr) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Like the frame's rect (see |GetRect|), which is the border rect,
|
2008-11-19 20:42:55 -08:00
|
|
|
* other rectangles of the frame, in app units, relative to the parent.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
nsRect GetPaddingRect() const;
|
2011-04-18 20:07:22 -07:00
|
|
|
nsRect GetPaddingRectRelativeToSelf() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect GetContentRect() const;
|
2011-04-18 20:07:22 -07:00
|
|
|
nsRect GetContentRectRelativeToSelf() const;
|
2013-12-03 11:13:16 -08:00
|
|
|
nsRect GetMarginRectRelativeToSelf() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-17 13:16:14 -07:00
|
|
|
/**
|
|
|
|
* The area to paint box-shadows around. The default is the border rect.
|
|
|
|
* (nsFieldSetFrame overrides this).
|
|
|
|
*/
|
|
|
|
virtual nsRect VisualBorderRectRelativeToSelf() const {
|
|
|
|
return nsRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
2010-09-07 15:20:34 -07:00
|
|
|
/**
|
|
|
|
* Get the size, in app units, of the border radii. It returns FALSE iff all
|
|
|
|
* returned radii == 0 (so no border radii), TRUE otherwise.
|
|
|
|
* For the aRadii indexes, use the NS_CORNER_* constants in nsStyleConsts.h
|
2010-09-07 15:20:34 -07:00
|
|
|
* If a side is skipped via aSkipSides, its corners are forced to 0.
|
2010-09-07 15:20:35 -07:00
|
|
|
*
|
|
|
|
* All corner radii are then adjusted so they do not require more
|
|
|
|
* space than aBorderArea, according to the algorithm in css3-background.
|
|
|
|
*
|
|
|
|
* aFrameSize is used as the basis for percentage widths and heights.
|
|
|
|
* aBorderArea is used for the adjustment of radii that might be too
|
|
|
|
* large.
|
|
|
|
* FIXME: In the long run, we can probably get away with only one of
|
|
|
|
* these, especially if we change the way we handle outline-radius (by
|
|
|
|
* removing it and inflating the border radius)
|
2010-09-07 15:20:35 -07:00
|
|
|
*
|
|
|
|
* Return whether any radii are nonzero.
|
2010-09-07 15:20:34 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool ComputeBorderRadii(const nsStyleCorners& aBorderRadius,
|
2010-09-07 15:20:34 -07:00
|
|
|
const nsSize& aFrameSize,
|
2010-09-07 15:20:35 -07:00
|
|
|
const nsSize& aBorderArea,
|
2012-08-09 00:09:40 -07:00
|
|
|
int aSkipSides,
|
2010-09-07 15:20:34 -07:00
|
|
|
nscoord aRadii[8]);
|
|
|
|
|
2010-09-07 15:20:35 -07:00
|
|
|
/*
|
|
|
|
* Given a set of border radii for one box (e.g., border box), convert
|
|
|
|
* it to the equivalent set of radii for another box (e.g., in to
|
|
|
|
* padding box, out to outline box) by reducing radii or increasing
|
|
|
|
* nonzero radii as appropriate.
|
|
|
|
*
|
|
|
|
* Indices into aRadii are the NS_CORNER_* constants in nsStyleConsts.h
|
|
|
|
*
|
|
|
|
* Note that InsetBorderRadii is lossy, since it can turn nonzero
|
|
|
|
* radii into zero, and OutsetBorderRadii does not inflate zero radii.
|
|
|
|
* Therefore, callers should always inset or outset directly from the
|
|
|
|
* original value coming from style.
|
|
|
|
*/
|
|
|
|
static void InsetBorderRadii(nscoord aRadii[8], const nsMargin &aOffsets);
|
|
|
|
static void OutsetBorderRadii(nscoord aRadii[8], const nsMargin &aOffsets);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in border radii for this frame. Return whether any are
|
|
|
|
* nonzero.
|
|
|
|
*
|
|
|
|
* Indices into aRadii are the NS_CORNER_* constants in nsStyleConsts.h
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool GetBorderRadii(nscoord aRadii[8]) const;
|
2010-09-07 15:20:35 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetPaddingBoxBorderRadii(nscoord aRadii[8]) const;
|
|
|
|
bool GetContentBoxBorderRadii(nscoord aRadii[8]) const;
|
2010-09-07 15:20:35 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the position of the frame's baseline, relative to the top of
|
|
|
|
* the frame (its top border edge). Only valid when Reflow is not
|
2010-08-31 11:54:44 -07:00
|
|
|
* needed.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
virtual nscoord GetBaseline() const = 0;
|
|
|
|
|
2010-08-31 11:54:44 -07:00
|
|
|
/**
|
|
|
|
* Get the position of the baseline on which the caret needs to be placed,
|
|
|
|
* relative to the top of the frame. This is mostly needed for frames
|
|
|
|
* which return a baseline from GetBaseline which is not useful for
|
|
|
|
* caret positioning.
|
|
|
|
*/
|
|
|
|
virtual nscoord GetCaretBaseline() const {
|
|
|
|
return GetBaseline();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2009-07-28 05:51:09 -07:00
|
|
|
* Get the specified child list.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2011-08-24 13:54:29 -07:00
|
|
|
* @param aListID identifies the requested child list.
|
|
|
|
* @return the child list. If the requested list is unsupported by this
|
|
|
|
* frame type, an empty list will be returned.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-03-07 17:57:37 -08:00
|
|
|
virtual const nsFrameList& GetChildList(ChildListID aListID) const = 0;
|
|
|
|
const nsFrameList& PrincipalChildList() { return GetChildList(kPrincipalList); }
|
2011-08-24 13:54:29 -07:00
|
|
|
virtual void GetChildLists(nsTArray<ChildList>* aLists) const = 0;
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the child lists for this frame, including
|
|
|
|
* ones belong to a child document.
|
|
|
|
*/
|
|
|
|
void GetCrossDocChildLists(nsTArray<ChildList>* aLists);
|
|
|
|
|
2009-07-28 05:51:09 -07:00
|
|
|
// XXXbz this method should go away
|
2011-08-24 13:54:29 -07:00
|
|
|
nsIFrame* GetFirstChild(ChildListID aListID) const {
|
|
|
|
return GetChildList(aListID).FirstChild();
|
2009-07-28 05:51:09 -07:00
|
|
|
}
|
2009-09-18 04:09:36 -07:00
|
|
|
// XXXmats this method should also go away then
|
2011-08-24 13:54:29 -07:00
|
|
|
nsIFrame* GetLastChild(ChildListID aListID) const {
|
|
|
|
return GetChildList(aListID).LastChild();
|
2009-09-18 04:09:36 -07:00
|
|
|
}
|
2011-08-24 13:54:29 -07:00
|
|
|
nsIFrame* GetFirstPrincipalChild() const {
|
|
|
|
return GetFirstChild(kPrincipalList);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The individual concrete child lists.
|
|
|
|
static const ChildListID kPrincipalList = mozilla::layout::kPrincipalList;
|
|
|
|
static const ChildListID kAbsoluteList = mozilla::layout::kAbsoluteList;
|
|
|
|
static const ChildListID kBulletList = mozilla::layout::kBulletList;
|
|
|
|
static const ChildListID kCaptionList = mozilla::layout::kCaptionList;
|
|
|
|
static const ChildListID kColGroupList = mozilla::layout::kColGroupList;
|
|
|
|
static const ChildListID kExcessOverflowContainersList = mozilla::layout::kExcessOverflowContainersList;
|
|
|
|
static const ChildListID kFixedList = mozilla::layout::kFixedList;
|
|
|
|
static const ChildListID kFloatList = mozilla::layout::kFloatList;
|
|
|
|
static const ChildListID kOverflowContainersList = mozilla::layout::kOverflowContainersList;
|
|
|
|
static const ChildListID kOverflowList = mozilla::layout::kOverflowList;
|
|
|
|
static const ChildListID kOverflowOutOfFlowList = mozilla::layout::kOverflowOutOfFlowList;
|
|
|
|
static const ChildListID kPopupList = mozilla::layout::kPopupList;
|
|
|
|
static const ChildListID kPushedFloatsList = mozilla::layout::kPushedFloatsList;
|
|
|
|
static const ChildListID kSelectPopupList = mozilla::layout::kSelectPopupList;
|
|
|
|
// A special alias for kPrincipalList that do not request reflow.
|
|
|
|
static const ChildListID kNoReflowPrincipalList = mozilla::layout::kNoReflowPrincipalList;
|
2009-07-29 05:53:27 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2009-10-02 09:27:37 -07:00
|
|
|
* Child frames are linked together in a doubly-linked list
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
nsIFrame* GetNextSibling() const { return mNextSibling; }
|
|
|
|
void SetNextSibling(nsIFrame* aNextSibling) {
|
2009-10-02 09:27:37 -07:00
|
|
|
NS_ASSERTION(this != aNextSibling, "Creating a circular frame list, this is very bad.");
|
|
|
|
if (mNextSibling && mNextSibling->GetPrevSibling() == this) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mNextSibling->mPrevSibling = nullptr;
|
2009-10-02 09:27:37 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
mNextSibling = aNextSibling;
|
2009-10-02 09:27:37 -07:00
|
|
|
if (mNextSibling) {
|
|
|
|
mNextSibling->mPrevSibling = this;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-10-02 09:27:37 -07:00
|
|
|
nsIFrame* GetPrevSibling() const { return mPrevSibling; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Builds the display lists for the content represented by this frame
|
|
|
|
* and its descendants. The background+borders of this element must
|
|
|
|
* be added first, before any other content.
|
|
|
|
*
|
|
|
|
* This should only be called by methods in nsFrame. Instead of calling this
|
|
|
|
* directly, call either BuildDisplayListForStackingContext or
|
|
|
|
* BuildDisplayListForChild.
|
|
|
|
*
|
|
|
|
* See nsDisplayList.h for more information about display lists.
|
|
|
|
*
|
|
|
|
* @param aDirtyRect content outside this rectangle can be ignored; the
|
|
|
|
* rectangle is in frame coordinates
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Displays the caret onto the given display list builder. The caret is
|
|
|
|
* painted on top of the rest of the display list items.
|
|
|
|
*
|
|
|
|
* @param aDirtyRect is the dirty rectangle that we're repainting.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplayCaret(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsDisplayList* aList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-31 19:35:48 -07:00
|
|
|
/**
|
|
|
|
* Get the preferred caret color at the offset.
|
|
|
|
*
|
|
|
|
* @param aOffset is offset of the content.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nscolor GetCaretColorAt(int32_t aOffset);
|
2010-03-31 19:35:48 -07:00
|
|
|
|
2010-06-10 15:53:57 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
bool IsThemed(nsITheme::Transparency* aTransparencyState = nullptr) const {
|
2013-02-16 13:51:02 -08:00
|
|
|
return IsThemed(StyleDisplay(), aTransparencyState);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsThemed(const nsStyleDisplay* aDisp,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsITheme::Transparency* aTransparencyState = nullptr) const {
|
2010-10-06 21:25:47 -07:00
|
|
|
nsIFrame* mutable_this = const_cast<nsIFrame*>(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!aDisp->mAppearance)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* pc = PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsITheme *theme = pc->GetTheme();
|
2010-10-06 21:25:47 -07:00
|
|
|
if(!theme ||
|
|
|
|
!theme->ThemeSupportsWidget(pc, mutable_this, aDisp->mAppearance))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-10 15:53:57 -07:00
|
|
|
if (aTransparencyState) {
|
2010-10-06 21:25:47 -07:00
|
|
|
*aTransparencyState =
|
|
|
|
theme->GetWidgetTransparency(mutable_this, aDisp->mAppearance);
|
2008-12-15 05:43:31 -08:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a display list for the content represented by this frame,
|
|
|
|
* treating this frame as the root of a stacking context.
|
|
|
|
* @param aDirtyRect content outside this rectangle can be ignored; the
|
|
|
|
* rectangle is in frame coordinates
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsDisplayList* aList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
enum {
|
|
|
|
DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT = 0x01,
|
|
|
|
DISPLAY_CHILD_FORCE_STACKING_CONTEXT = 0x02,
|
|
|
|
DISPLAY_CHILD_INLINE = 0x04
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Adjusts aDirtyRect for the child's offset, checks that the dirty rect
|
|
|
|
* actually intersects the child (or its descendants), calls BuildDisplayList
|
|
|
|
* on the child if necessary, and puts things in the right lists if the child
|
|
|
|
* is positioned.
|
|
|
|
*
|
|
|
|
* @param aFlags combination of DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT,
|
|
|
|
* DISPLAY_CHILD_FORCE_STACKING_CONTEXT and DISPLAY_CHILD_INLINE
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aChild,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists,
|
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2010-01-11 13:45:19 -08:00
|
|
|
* Does this frame need a view?
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool NeedsView() { return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
2012-05-16 21:05:09 -07:00
|
|
|
* Returns true if this frame is transformed (e.g. has CSS or SVG transforms)
|
|
|
|
* or if its parent is an SVG frame that has children-only transforms (e.g.
|
|
|
|
* an SVG viewBox attribute).
|
|
|
|
*/
|
|
|
|
bool IsTransformed() const;
|
2012-07-31 10:28:21 -07:00
|
|
|
|
|
|
|
bool HasOpacity() const;
|
2012-05-16 21:05:09 -07:00
|
|
|
|
2012-10-02 22:55:50 -07:00
|
|
|
/**
|
|
|
|
* Return true if this frame might be using a transform getter.
|
|
|
|
*/
|
|
|
|
virtual bool HasTransformGetter() const { return false; }
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
/**
|
|
|
|
* Returns true if this frame is an SVG frame that has SVG transforms applied
|
|
|
|
* to it, or if its parent frame is an SVG frame that has children-only
|
|
|
|
* transforms (e.g. an SVG viewBox attribute).
|
|
|
|
* If aOwnTransforms is non-null and the frame has its own SVG transforms,
|
|
|
|
* aOwnTransforms will be set to these transforms. If aFromParentTransforms
|
|
|
|
* is non-null and the frame has an SVG parent with children-only transforms,
|
|
|
|
* then aFromParentTransforms will be set to these transforms.
|
2008-09-13 02:42:11 -07:00
|
|
|
*/
|
2013-12-29 22:50:07 -08:00
|
|
|
virtual bool IsSVGTransformed(Matrix *aOwnTransforms = nullptr,
|
|
|
|
Matrix *aFromParentTransforms = nullptr) const;
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2011-08-26 17:01:46 -07:00
|
|
|
/**
|
|
|
|
* Returns whether this frame will attempt to preserve the 3d transforms of its
|
|
|
|
* children. This is a direct indicator of -moz-transform-style: preserve-3d.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Preserves3DChildren() const;
|
2011-08-26 17:01:46 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this frame has a parent that Preserves3DChildren() and
|
|
|
|
* can respect this. Returns false if the frame is clipped.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Preserves3D() const;
|
2011-08-26 17:01:46 -07:00
|
|
|
|
2012-02-15 01:28:22 -08:00
|
|
|
bool HasPerspective() const;
|
|
|
|
|
2012-03-11 19:04:25 -07:00
|
|
|
bool ChildrenHavePerspective() const;
|
|
|
|
|
2011-08-26 17:01:46 -07:00
|
|
|
// Calculate the overflow size of all child frames, taking preserve-3d into account
|
|
|
|
void ComputePreserve3DChildrenOverflow(nsOverflowAreas& aOverflowAreas, const nsRect& aBounds);
|
|
|
|
|
2012-03-11 19:04:25 -07:00
|
|
|
void RecomputePerspectiveChildrenOverflow(const nsStyleContext* aStartStyle, const nsRect* aBounds);
|
2012-02-15 01:28:22 -08:00
|
|
|
|
2012-12-09 18:32:55 -08:00
|
|
|
/**
|
|
|
|
* Returns the number of ancestors between this and the root of our frame tree
|
|
|
|
*/
|
|
|
|
uint32_t GetDepthInFrameTree() {
|
|
|
|
uint32_t result = 0;
|
|
|
|
for (nsIFrame* ancestor = GetParent(); ancestor;
|
|
|
|
ancestor = ancestor->GetParent()) {
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Event handling of GUI events.
|
|
|
|
*
|
|
|
|
* @param aEvent event structure describing the type of event and rge widget
|
|
|
|
* where the event originated
|
|
|
|
* The |point| member of this is in the coordinate system of the
|
|
|
|
* view returned by GetOffsetFromView.
|
|
|
|
* @param aEventStatus a return value indicating whether the event was handled
|
|
|
|
* and whether default processing should be done
|
|
|
|
*
|
|
|
|
* XXX From a frame's perspective it's unclear what the effect of the event status
|
|
|
|
* is. Does it cause the event to continue propagating through the frame hierarchy
|
|
|
|
* or is it just returned to the widgets?
|
|
|
|
*
|
2013-10-01 20:46:03 -07:00
|
|
|
* @see WidgetGUIEvent
|
2007-03-22 10:30:00 -07:00
|
|
|
* @see nsEventStatus
|
|
|
|
*/
|
|
|
|
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-01 20:46:04 -07:00
|
|
|
NS_IMETHOD GetContentForEvent(mozilla::WidgetEvent* aEvent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIContent** aContent) = 0;
|
|
|
|
|
|
|
|
// This structure keeps track of the content node and offsets associated with
|
|
|
|
// a point; there is a primary and a secondary offset associated with any
|
|
|
|
// point. The primary and secondary offsets differ when the point is over a
|
|
|
|
// non-text object. The primary offset is the expected position of the
|
|
|
|
// cursor calculated from a point; the secondary offset, when it is different,
|
|
|
|
// indicates that the point is in the boundaries of some selectable object.
|
|
|
|
// Note that the primary offset can be after the secondary offset; for places
|
|
|
|
// that need the beginning and end of the object, the StartOffset and
|
|
|
|
// EndOffset helpers can be used.
|
2013-04-11 20:20:45 -07:00
|
|
|
struct MOZ_STACK_CLASS ContentOffsets {
|
2013-10-01 14:00:38 -07:00
|
|
|
ContentOffsets();
|
|
|
|
ContentOffsets(const ContentOffsets&);
|
|
|
|
~ContentOffsets();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> content;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsNull() { return !content; }
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t offset;
|
|
|
|
int32_t secondaryOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Helpers for places that need the ends of the offsets and expect them in
|
|
|
|
// numerical order, as opposed to wanting the primary and secondary offsets
|
2013-01-15 04:22:03 -08:00
|
|
|
int32_t StartOffset() { return std::min(offset, secondaryOffset); }
|
|
|
|
int32_t EndOffset() { return std::max(offset, secondaryOffset); }
|
2007-03-22 10:30:00 -07:00
|
|
|
// This boolean indicates whether the associated content is before or after
|
|
|
|
// the offset; the most visible use is to allow the caret to know which line
|
|
|
|
// to display on.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool associateWithNext;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
2012-05-29 06:13:36 -07:00
|
|
|
enum {
|
|
|
|
IGNORE_SELECTION_STYLE = 0x01,
|
|
|
|
// Treat visibility:hidden frames as non-selectable
|
|
|
|
SKIP_HIDDEN = 0x02
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* This function calculates the content offsets for selection relative to
|
|
|
|
* a point. Note that this should generally only be callled on the event
|
|
|
|
* frame associated with an event because this function does not account
|
|
|
|
* for frame lists other than the primary one.
|
|
|
|
* @param aPoint point relative to this frame
|
|
|
|
*/
|
|
|
|
ContentOffsets GetContentOffsetsFromPoint(nsPoint aPoint,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual ContentOffsets GetContentOffsetsFromPointExternal(nsPoint aPoint,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0)
|
2012-05-29 06:13:36 -07:00
|
|
|
{ return GetContentOffsetsFromPoint(aPoint, aFlags); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-19 01:40:02 -07:00
|
|
|
/**
|
|
|
|
* Ensure that aImage gets notifed when the underlying image request loads
|
|
|
|
* or animates.
|
|
|
|
*/
|
2013-08-14 04:29:11 -07:00
|
|
|
void AssociateImage(const nsStyleImage& aImage, nsPresContext* aPresContext);
|
2013-07-19 01:40:02 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* This structure holds information about a cursor. mContainer represents a
|
|
|
|
* loaded image that should be preferred. If it is not possible to use it, or
|
|
|
|
* if it is null, mCursor should be used.
|
|
|
|
*/
|
2013-04-11 20:20:45 -07:00
|
|
|
struct MOZ_STACK_CLASS Cursor {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<imgIContainer> mContainer;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mCursor;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHaveHotspot;
|
2007-03-22 10:30:00 -07:00
|
|
|
float mHotspotX, mHotspotY;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Get the cursor for a given frame.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetCursor(const nsPoint& aPoint,
|
|
|
|
Cursor& aCursor) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a point (in the frame's coordinate space) given an offset into
|
|
|
|
* the content. This point should be on the baseline of text with
|
|
|
|
* the correct horizontal offset
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetPointFromOffset(int32_t inOffset,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPoint* outPoint) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the child frame of this frame which contains the given
|
2012-07-30 07:20:58 -07:00
|
|
|
* content offset. outChildFrame may be this frame, or nullptr on return.
|
2007-03-22 10:30:00 -07:00
|
|
|
* outContentOffset returns the content offset relative to the start
|
|
|
|
* of the returned node. You can also pass a hint which tells the method
|
|
|
|
* to stick to the end of the first found frame or the beginning of the
|
|
|
|
* next in case the offset falls on a boundary.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetChildFrameContainingOffset(int32_t inContentOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool inHint,//false stick left
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* outFrameContentOffset,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* *outChildFrame) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current frame-state value for this frame. aResult is
|
|
|
|
* filled in with the state bits.
|
|
|
|
*/
|
|
|
|
nsFrameState GetStateBits() const { return mState; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the current frame-state value for this frame.
|
|
|
|
*/
|
|
|
|
void AddStateBits(nsFrameState aBits) { mState |= aBits; }
|
|
|
|
void RemoveStateBits(nsFrameState aBits) { mState &= ~aBits; }
|
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
/**
|
|
|
|
* Checks if the current frame-state includes all of the listed bits
|
|
|
|
*/
|
|
|
|
bool HasAllStateBits(nsFrameState aBits) { return (mState & aBits) == aBits; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the current frame-state includes any of the listed bits
|
|
|
|
*/
|
|
|
|
bool HasAnyStateBits(nsFrameState aBits) { return mState & aBits; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2009-08-04 18:38:10 -07:00
|
|
|
* This call is invoked on the primary frame for a character data content
|
|
|
|
* node, when it is changed in the content tree.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-08-04 18:38:10 -07:00
|
|
|
NS_IMETHOD CharacterDataChanged(CharacterDataChangeInfo* aInfo) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This call is invoked when the value of a content objects's attribute
|
|
|
|
* is changed.
|
|
|
|
* The first frame that maps that content is asked to deal
|
|
|
|
* with the change by doing whatever is appropriate.
|
|
|
|
*
|
|
|
|
* @param aNameSpaceID the namespace of the attribute
|
|
|
|
* @param aAttribute the atom name of the attribute
|
|
|
|
* @param aModType Whether or not the attribute was added, changed, or removed.
|
|
|
|
* The constants are defined in nsIDOMMutationEvent.h.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-14 10:00:57 -08:00
|
|
|
/**
|
|
|
|
* When the content states of a content object change, this method is invoked
|
|
|
|
* on the primary frame of that content object.
|
|
|
|
*
|
|
|
|
* @param aStates the changed states
|
|
|
|
*/
|
2012-07-14 21:14:06 -07:00
|
|
|
virtual void ContentStatesChanged(nsEventStates aStates) { }
|
2010-12-14 10:00:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Return how your frame can be split.
|
|
|
|
*/
|
|
|
|
virtual nsSplittableType GetSplittableType() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Continuation member functions
|
|
|
|
*/
|
|
|
|
virtual nsIFrame* GetPrevContinuation() const = 0;
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetPrevContinuation(nsIFrame*) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsIFrame* GetNextContinuation() const = 0;
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetNextContinuation(nsIFrame*) = 0;
|
2013-09-25 04:42:34 -07:00
|
|
|
virtual nsIFrame* FirstContinuation() const {
|
2007-07-08 00:08:04 -07:00
|
|
|
return const_cast<nsIFrame*>(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-09-25 04:42:34 -07:00
|
|
|
virtual nsIFrame* LastContinuation() const {
|
2007-07-08 00:08:04 -07:00
|
|
|
return const_cast<nsIFrame*>(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-01-27 00:13:19 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GetTailContinuation gets the last non-overflow-container continuation
|
|
|
|
* in the continuation chain, i.e. where the next sibling element
|
|
|
|
* should attach).
|
|
|
|
*/
|
|
|
|
nsIFrame* GetTailContinuation();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Flow member functions
|
|
|
|
*/
|
|
|
|
virtual nsIFrame* GetPrevInFlowVirtual() const = 0;
|
|
|
|
nsIFrame* GetPrevInFlow() const { return GetPrevInFlowVirtual(); }
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetPrevInFlow(nsIFrame*) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nsIFrame* GetNextInFlowVirtual() const = 0;
|
|
|
|
nsIFrame* GetNextInFlow() const { return GetNextInFlowVirtual(); }
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetNextInFlow(nsIFrame*) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first frame in our current flow.
|
|
|
|
*/
|
2013-09-25 04:42:34 -07:00
|
|
|
virtual nsIFrame* FirstInFlow() const {
|
2007-07-08 00:08:04 -07:00
|
|
|
return const_cast<nsIFrame*>(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the last frame in our current flow.
|
|
|
|
*/
|
2013-09-25 04:42:34 -07:00
|
|
|
virtual nsIFrame* LastInFlow() const {
|
2007-07-08 00:08:04 -07:00
|
|
|
return const_cast<nsIFrame*>(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark any stored intrinsic width information as dirty (requiring
|
|
|
|
* re-calculation). Note that this should generally not be called
|
|
|
|
* directly; nsPresShell::FrameNeedsReflow will call it instead.
|
|
|
|
*/
|
|
|
|
virtual void MarkIntrinsicWidthsDirty() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the intrinsic minimum width of the frame. This must be less
|
|
|
|
* than or equal to the intrinsic width.
|
|
|
|
*
|
|
|
|
* This is *not* affected by the CSS 'min-width', 'width', and
|
|
|
|
* 'max-width' properties on this frame, but it is affected by the
|
|
|
|
* values of those properties on this frame's descendants. (It may be
|
|
|
|
* called during computation of the values of those properties, so it
|
|
|
|
* cannot depend on any values in the nsStylePosition for this frame.)
|
|
|
|
*
|
|
|
|
* The value returned should **NOT** include the space required for
|
|
|
|
* padding and border.
|
|
|
|
*
|
|
|
|
* Note that many frames will cache the result of this function call
|
|
|
|
* unless MarkIntrinsicWidthsDirty is called.
|
|
|
|
*
|
|
|
|
* It is not acceptable for a frame to mark itself dirty when this
|
|
|
|
* method is called.
|
2008-07-28 23:07:28 -07:00
|
|
|
*
|
|
|
|
* This method must not return a negative value.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the intrinsic width of the frame. This must be greater than or
|
|
|
|
* equal to the intrinsic minimum width.
|
|
|
|
*
|
|
|
|
* Otherwise, all the comments for |GetMinWidth| above apply.
|
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* |InlineIntrinsicWidth| represents the intrinsic width information
|
|
|
|
* in inline layout. Code that determines the intrinsic width of a
|
|
|
|
* region of inline layout accumulates the result into this structure.
|
|
|
|
* This pattern is needed because we need to maintain state
|
|
|
|
* information about whitespace (for both collapsing and trimming).
|
|
|
|
*/
|
|
|
|
struct InlineIntrinsicWidthData {
|
|
|
|
InlineIntrinsicWidthData()
|
2012-07-30 07:20:58 -07:00
|
|
|
: line(nullptr)
|
|
|
|
, lineContainer(nullptr)
|
2007-09-17 20:00:16 -07:00
|
|
|
, prevLines(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
, currentLine(0)
|
2011-10-17 07:59:28 -07:00
|
|
|
, skipWhitespace(true)
|
2007-03-22 10:30:00 -07:00
|
|
|
, trailingWhitespace(0)
|
|
|
|
{}
|
|
|
|
|
2008-01-09 19:18:44 -08:00
|
|
|
// The line. This may be null if the inlines are not associated with
|
|
|
|
// a block or if we just don't know the line.
|
2007-09-17 20:00:16 -07:00
|
|
|
const nsLineList_iterator* line;
|
|
|
|
|
2009-02-10 01:23:05 -08:00
|
|
|
// The line container.
|
|
|
|
nsIFrame* lineContainer;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// The maximum intrinsic width for all previous lines.
|
|
|
|
nscoord prevLines;
|
|
|
|
|
|
|
|
// The maximum intrinsic width for the current line. At a line
|
|
|
|
// break (mandatory for preferred width; allowed for minimum width),
|
|
|
|
// the caller should call |Break()|.
|
|
|
|
nscoord currentLine;
|
|
|
|
|
|
|
|
// True if initial collapsable whitespace should be skipped. This
|
2007-12-11 16:42:20 -08:00
|
|
|
// should be true at the beginning of a block, after hard breaks
|
|
|
|
// and when the last text ended with whitespace.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool skipWhitespace;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// This contains the width of the trimmable whitespace at the end of
|
|
|
|
// |currentLine|; it is zero if there is no such whitespace.
|
|
|
|
nscoord trailingWhitespace;
|
|
|
|
|
|
|
|
// Floats encountered in the lines.
|
2012-08-10 04:16:52 -07:00
|
|
|
class FloatInfo {
|
|
|
|
public:
|
|
|
|
FloatInfo(const nsIFrame* aFrame, nscoord aWidth)
|
|
|
|
: mFrame(aFrame), mWidth(aWidth)
|
|
|
|
{ }
|
|
|
|
const nsIFrame* Frame() const { return mFrame; }
|
|
|
|
nscoord Width() const { return mWidth; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const nsIFrame* mFrame;
|
|
|
|
nscoord mWidth;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsTArray<FloatInfo> floats;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct InlineMinWidthData : public InlineIntrinsicWidthData {
|
|
|
|
InlineMinWidthData()
|
2012-07-30 07:20:58 -07:00
|
|
|
: trailingTextFrame(nullptr)
|
2011-10-17 07:59:28 -07:00
|
|
|
, atStartOfLine(true)
|
2007-03-22 10:30:00 -07:00
|
|
|
{}
|
|
|
|
|
2007-06-21 15:32:47 -07:00
|
|
|
// We need to distinguish forced and optional breaks for cases where the
|
|
|
|
// current line total is negative. When it is, we need to ignore
|
|
|
|
// optional breaks to prevent min-width from ending up bigger than
|
|
|
|
// pref-width.
|
2011-04-07 18:04:40 -07:00
|
|
|
void ForceBreak(nsRenderingContext *aRenderingContext);
|
2011-03-24 08:22:37 -07:00
|
|
|
|
|
|
|
// If the break here is actually taken, aHyphenWidth must be added to the
|
|
|
|
// width of the current line.
|
2011-04-07 18:04:40 -07:00
|
|
|
void OptionallyBreak(nsRenderingContext *aRenderingContext,
|
2011-03-24 08:22:37 -07:00
|
|
|
nscoord aHyphenWidth = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// The last text frame processed so far in the current line, when
|
|
|
|
// the last characters in that text frame are relevant for line
|
|
|
|
// break opportunities.
|
|
|
|
nsIFrame *trailingTextFrame;
|
2007-06-21 15:32:47 -07:00
|
|
|
|
|
|
|
// Whether we're currently at the start of the line. If we are, we
|
|
|
|
// can't break (for example, between the text-indent and the first
|
|
|
|
// word).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool atStartOfLine;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct InlinePrefWidthData : public InlineIntrinsicWidthData {
|
2011-04-07 18:04:40 -07:00
|
|
|
void ForceBreak(nsRenderingContext *aRenderingContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the intrinsic minimum width of a frame in a way suitable for
|
|
|
|
* use in inline layout to an |InlineIntrinsicWidthData| object that
|
|
|
|
* represents the intrinsic width information of all the previous
|
|
|
|
* frames in the inline layout region.
|
|
|
|
*
|
|
|
|
* All *allowed* breakpoints within the frame determine what counts as
|
|
|
|
* a line for the |InlineIntrinsicWidthData|. This means that
|
|
|
|
* |aData->trailingWhitespace| will always be zero (unlike for
|
|
|
|
* AddInlinePrefWidth).
|
|
|
|
*
|
|
|
|
* All the comments for |GetMinWidth| apply, except that this function
|
|
|
|
* is responsible for adding padding, border, and margin and for
|
|
|
|
* considering the effects of 'width', 'min-width', and 'max-width'.
|
|
|
|
*
|
|
|
|
* This may be called on any frame. Frames that do not participate in
|
|
|
|
* line breaking can inherit the default implementation on nsFrame,
|
|
|
|
* which calls |GetMinWidth|.
|
|
|
|
*/
|
|
|
|
virtual void
|
2011-04-07 18:04:40 -07:00
|
|
|
AddInlineMinWidth(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
InlineMinWidthData *aData) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the intrinsic preferred width of a frame in a way suitable for
|
|
|
|
* use in inline layout to an |InlineIntrinsicWidthData| object that
|
|
|
|
* represents the intrinsic width information of all the previous
|
|
|
|
* frames in the inline layout region.
|
|
|
|
*
|
|
|
|
* All the comments for |AddInlineMinWidth| and |GetPrefWidth| apply,
|
|
|
|
* except that this fills in an |InlineIntrinsicWidthData| structure
|
|
|
|
* based on using all *mandatory* breakpoints within the frame.
|
|
|
|
*/
|
|
|
|
virtual void
|
2011-04-07 18:04:40 -07:00
|
|
|
AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
InlinePrefWidthData *aData) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the horizontal components of padding, border, and margin
|
|
|
|
* that contribute to the intrinsic width that applies to the parent.
|
|
|
|
*/
|
|
|
|
struct IntrinsicWidthOffsetData {
|
|
|
|
nscoord hPadding, hBorder, hMargin;
|
|
|
|
float hPctPadding, hPctMargin;
|
|
|
|
|
|
|
|
IntrinsicWidthOffsetData()
|
|
|
|
: hPadding(0), hBorder(0), hMargin(0)
|
|
|
|
, hPctPadding(0.0f), hPctMargin(0.0f)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
virtual IntrinsicWidthOffsetData
|
2011-04-07 18:04:40 -07:00
|
|
|
IntrinsicWidthOffsets(nsRenderingContext* aRenderingContext) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-30 14:26:04 -07:00
|
|
|
virtual mozilla::IntrinsicSize GetIntrinsicSize() = 0;
|
2007-11-18 04:09:03 -08:00
|
|
|
|
2007-06-12 11:27:09 -07:00
|
|
|
/*
|
|
|
|
* Get the intrinsic ratio of this element, or nsSize(0,0) if it has
|
|
|
|
* no intrinsic ratio. The intrinsic ratio is the ratio of the
|
|
|
|
* height/width of a box with an intrinsic size or the intrinsic
|
|
|
|
* aspect ratio of a scalable vector image without an intrinsic size.
|
|
|
|
*
|
|
|
|
* Either one of the sides may be zero, indicating a zero or infinite
|
|
|
|
* ratio.
|
|
|
|
*/
|
|
|
|
virtual nsSize GetIntrinsicRatio() = 0;
|
|
|
|
|
2012-03-16 11:01:05 -07:00
|
|
|
/**
|
|
|
|
* Bit-flags to pass to ComputeSize in |aFlags| parameter.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
/* Set if the frame is in a context where non-replaced blocks should
|
|
|
|
* shrink-wrap (e.g., it's floating, absolutely positioned, or
|
|
|
|
* inline-block). */
|
2012-09-29 23:38:46 -07:00
|
|
|
eShrinkWrap = 1 << 0,
|
|
|
|
/* Set if we'd like to compute our 'auto' height, regardless of our actual
|
|
|
|
* computed value of 'height'. (e.g. to get an intrinsic height for flex
|
|
|
|
* items with "min-height: auto" to use during flexbox layout.) */
|
|
|
|
eUseAutoHeight = 1 << 1
|
2012-03-16 11:01:05 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Compute the size that a frame will occupy. Called while
|
|
|
|
* constructing the nsHTMLReflowState to be used to Reflow the frame,
|
|
|
|
* in order to fill its mComputedWidth and mComputedHeight member
|
|
|
|
* variables.
|
|
|
|
*
|
|
|
|
* The |height| member of the return value may be
|
|
|
|
* NS_UNCONSTRAINEDSIZE, but the |width| member must not be.
|
|
|
|
*
|
|
|
|
* Note that the reason that border and padding need to be passed
|
|
|
|
* separately is so that the 'box-sizing' property can be handled.
|
|
|
|
* Thus aMargin includes absolute positioning offsets as well.
|
|
|
|
*
|
|
|
|
* @param aCBSize The size of the element's containing block. (Well,
|
|
|
|
* the |height| component isn't really.)
|
|
|
|
* @param aAvailableWidth The available width for 'auto' widths.
|
|
|
|
* This is usually the same as aCBSize.width,
|
|
|
|
* but differs in cases such as block
|
|
|
|
* formatting context roots next to floats, or
|
|
|
|
* in some cases of float reflow in quirks
|
|
|
|
* mode.
|
|
|
|
* @param aMargin The sum of the vertical / horizontal margins
|
|
|
|
* ***AND*** absolute positioning offsets (top, right,
|
|
|
|
* bottom, left) of the frame, including actual values
|
|
|
|
* resulting from percentages and from the
|
|
|
|
* "hypothetical box" for absolute positioning, but
|
|
|
|
* not including actual values resulting from 'auto'
|
|
|
|
* margins or ignored 'auto' values in absolute
|
|
|
|
* positioning.
|
|
|
|
* @param aBorder The sum of the vertical / horizontal border widths
|
|
|
|
* of the frame.
|
2012-03-16 11:01:05 -07:00
|
|
|
* @param aPadding The sum of the vertical / horizontal margins of
|
|
|
|
* the frame, including actual values resulting from
|
|
|
|
* percentages.
|
|
|
|
* @param aFlags Flags to further customize behavior (definitions above).
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-12 01:30:54 -07:00
|
|
|
/**
|
|
|
|
* Compute a tight bounding rectangle for the frame. This is a rectangle
|
|
|
|
* that encloses the pixels that are actually drawn. We're allowed to be
|
|
|
|
* conservative and currently we don't try very hard. The rectangle is
|
|
|
|
* in appunits and relative to the origin of this frame.
|
2010-10-06 21:25:46 -07:00
|
|
|
*
|
|
|
|
* This probably only needs to include frame bounds, glyph bounds, and
|
|
|
|
* text decorations, but today it sometimes includes other things that
|
|
|
|
* contribute to visual overflow.
|
|
|
|
*
|
2007-10-12 01:30:54 -07:00
|
|
|
* @param aContext a rendering context that can be used if we need
|
|
|
|
* to do measurement
|
|
|
|
*/
|
|
|
|
virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
|
|
|
|
|
2013-11-25 06:20:20 -08:00
|
|
|
/**
|
|
|
|
* This function is similar to GetPrefWidth and ComputeTightBounds: it
|
|
|
|
* computes the left and right coordinates of a preferred tight bounding
|
|
|
|
* rectangle for the frame. This is a rectangle that would enclose the pixels
|
|
|
|
* that are drawn if we lay out the element without taking any optional line
|
|
|
|
* breaks. The rectangle is in appunits and relative to the origin of this
|
|
|
|
* frame. Currently, this function is only implemented for nsBlockFrame and
|
|
|
|
* nsTextFrame and is used to determine intrinsic widths of MathML token
|
|
|
|
* elements.
|
|
|
|
|
|
|
|
* @param aContext a rendering context that can be used if we need
|
|
|
|
* to do measurement
|
|
|
|
* @param aX computed left coordinate of the tight bounding rectangle
|
|
|
|
* @param aXMost computed intrinsic width of the tight bounding rectangle
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
virtual nsresult GetPrefWidthTightBounds(nsRenderingContext* aContext,
|
|
|
|
nscoord* aX,
|
|
|
|
nscoord* aXMost);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Pre-reflow hook. Before a frame is reflowed this method will be called.
|
|
|
|
* This call will always be invoked at least once before a subsequent Reflow
|
|
|
|
* and DidReflow call. It may be called more than once, In general you will
|
|
|
|
* receive on WillReflow notification before each Reflow request.
|
|
|
|
*
|
|
|
|
* XXX Is this really the semantics we want? Because we have the NS_FRAME_IN_REFLOW
|
|
|
|
* bit we can ensure we don't call it more than once...
|
|
|
|
*/
|
|
|
|
NS_IMETHOD WillReflow(nsPresContext* aPresContext) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The frame is given an available size and asked for its desired
|
|
|
|
* size. This is the frame's opportunity to reflow its children.
|
|
|
|
*
|
|
|
|
* If the frame has the NS_FRAME_IS_DIRTY bit set then it is
|
|
|
|
* responsible for completely reflowing itself and all of its
|
|
|
|
* descendants.
|
|
|
|
*
|
|
|
|
* Otherwise, if the frame has the NS_FRAME_HAS_DIRTY_CHILDREN bit
|
|
|
|
* set, then it is responsible for reflowing at least those
|
|
|
|
* children that have NS_FRAME_HAS_DIRTY_CHILDREN or NS_FRAME_IS_DIRTY
|
|
|
|
* set.
|
|
|
|
*
|
|
|
|
* If a difference in available size from the previous reflow causes
|
|
|
|
* the frame's size to change, it should reflow descendants as needed.
|
|
|
|
*
|
|
|
|
* @param aReflowMetrics <i>out</i> parameter where you should return the
|
|
|
|
* desired size and ascent/descent info. You should include any
|
|
|
|
* space you want for border/padding in the desired size you return.
|
|
|
|
*
|
|
|
|
* It's okay to return a desired size that exceeds the avail
|
|
|
|
* size if that's the smallest you can be, i.e. it's your
|
|
|
|
* minimum size.
|
|
|
|
*
|
|
|
|
* For an incremental reflow you are responsible for invalidating
|
|
|
|
* any area within your frame that needs repainting (including
|
|
|
|
* borders). If your new desired size is different than your current
|
|
|
|
* size, then your parent frame is responsible for making sure that
|
|
|
|
* the difference between the two rects is repainted
|
|
|
|
*
|
|
|
|
* @param aReflowState information about your reflow including the reason
|
|
|
|
* for the reflow and the available space in which to lay out. Each
|
|
|
|
* dimension of the available space can either be constrained or
|
|
|
|
* unconstrained (a value of NS_UNCONSTRAINEDSIZE).
|
|
|
|
*
|
|
|
|
* Note that the available space can be negative. In this case you
|
|
|
|
* still must return an accurate desired size. If you're a container
|
|
|
|
* you must <b>always</b> reflow at least one frame regardless of the
|
|
|
|
* available space
|
|
|
|
*
|
|
|
|
* @param aStatus a return value indicating whether the frame is complete
|
|
|
|
* and whether the next-in-flow is dirty and needs to be reflowed
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aReflowMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Post-reflow hook. After a frame is reflowed this method will be called
|
|
|
|
* informing the frame that this reflow process is complete, and telling the
|
|
|
|
* frame the status returned by the Reflow member function.
|
|
|
|
*
|
|
|
|
* This call may be invoked many times, while NS_FRAME_IN_REFLOW is set, before
|
|
|
|
* it is finally called once with a NS_FRAME_REFLOW_COMPLETE value. When called
|
|
|
|
* with a NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
|
|
|
|
* frame state will be cleared.
|
|
|
|
*
|
|
|
|
* XXX This doesn't make sense. If the frame is reflowed but not complete, then
|
|
|
|
* the status should be NS_FRAME_NOT_COMPLETE and not NS_FRAME_COMPLETE
|
|
|
|
* XXX Don't we want the semantics to dictate that we only call this once for
|
|
|
|
* a given reflow?
|
|
|
|
*/
|
|
|
|
NS_IMETHOD DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus) = 0;
|
|
|
|
|
|
|
|
// XXX Maybe these three should be a separate interface?
|
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
/**
|
|
|
|
* Updates the overflow areas of the frame. This can be called if an
|
|
|
|
* overflow area of the frame's children has changed without reflowing.
|
|
|
|
* @return true if either of the overflow areas for this frame have changed.
|
|
|
|
*/
|
|
|
|
virtual bool UpdateOverflow() = 0;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Helper method used by block reflow to identify runs of text so
|
|
|
|
* that proper word-breaking can be done.
|
|
|
|
*
|
|
|
|
* @return
|
2011-10-17 07:59:28 -07:00
|
|
|
* true if we can continue a "text run" through the frame. A
|
2007-03-22 10:30:00 -07:00
|
|
|
* text run is text that should be treated contiguously for line
|
|
|
|
* and word breaking.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool CanContinueTextRun() const = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-03 18:12:24 -07:00
|
|
|
/**
|
|
|
|
* Append the rendered text to the passed-in string.
|
|
|
|
* The appended text will often not contain all the whitespace from source,
|
|
|
|
* depending on whether the CSS rule "white-space: pre" is active for this frame.
|
|
|
|
* if aStartOffset + aLength goes past end, or if aLength is not specified
|
|
|
|
* then use the text up to the string's end.
|
|
|
|
* Call this on the primary frame for a text node.
|
|
|
|
* @param aAppendToString String to append text to, or null if text should not be returned
|
|
|
|
* @param aSkipChars if aSkipIter is non-null, this must also be non-null.
|
|
|
|
* This gets used as backing data for the iterator so it should outlive the iterator.
|
|
|
|
* @param aSkipIter Where to fill in the gfxSkipCharsIterator info, or null if not needed by caller
|
|
|
|
* @param aStartOffset Skipped (rendered text) start offset
|
|
|
|
* @param aSkippedMaxLength Maximum number of characters to return
|
|
|
|
* The iterator can be used to map content offsets to offsets in the returned string, or vice versa.
|
|
|
|
*/
|
2012-07-30 07:20:58 -07:00
|
|
|
virtual nsresult GetRenderedText(nsAString* aAppendToString = nullptr,
|
|
|
|
gfxSkipChars* aSkipChars = nullptr,
|
|
|
|
gfxSkipCharsIterator* aSkipIter = nullptr,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aSkippedStartOffset = 0,
|
2012-09-27 23:57:33 -07:00
|
|
|
uint32_t aSkippedMaxLength = UINT32_MAX)
|
2007-08-03 18:12:24 -07:00
|
|
|
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
|
2010-08-13 15:58:26 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the frame contains any non-collapsed characters.
|
|
|
|
* This method is only available for text frames, and it will return false
|
|
|
|
* for all other frame types.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool HasAnyNoncollapsedCharacters()
|
2011-10-17 07:59:28 -07:00
|
|
|
{ return false; }
|
2010-08-13 15:58:26 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Accessor functions to get/set the associated view object
|
|
|
|
*
|
|
|
|
* GetView returns non-null if and only if |HasView| returns true.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasView() const { return !!(mState & NS_FRAME_HAS_VIEW); }
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* GetView() const;
|
|
|
|
virtual nsView* GetViewExternal() const;
|
|
|
|
nsresult SetView(nsView* aView);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the closest view (on |this| or an ancestor).
|
|
|
|
* If aOffset is non-null, it will be set to the offset of |this|
|
|
|
|
* from the returned view.
|
|
|
|
*/
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* GetClosestView(nsPoint* aOffset = nullptr) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the closest ancestor (excluding |this| !) that has a view
|
|
|
|
*/
|
|
|
|
nsIFrame* GetAncestorWithView() const;
|
|
|
|
virtual nsIFrame* GetAncestorWithViewExternal() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the offset between the coordinate systems of |this| and aOther.
|
|
|
|
* Adding the return value to a point in the coordinate system of |this|
|
|
|
|
* will transform the point to the coordinate system of aOther.
|
|
|
|
*
|
|
|
|
* aOther must be non-null.
|
|
|
|
*
|
|
|
|
* This function is fastest when aOther is an ancestor of |this|.
|
|
|
|
*
|
2010-07-18 19:23:47 -07:00
|
|
|
* This function _DOES NOT_ work across document boundaries.
|
|
|
|
* Use this function only when |this| and aOther are in the same document.
|
2009-07-21 17:45:00 -07:00
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* NOTE: this actually returns the offset from aOther to |this|, but
|
|
|
|
* that offset is added to transform _coordinates_ from |this| to
|
|
|
|
* aOther.
|
|
|
|
*/
|
|
|
|
nsPoint GetOffsetTo(const nsIFrame* aOther) const;
|
|
|
|
virtual nsPoint GetOffsetToExternal(const nsIFrame* aOther) const;
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
/**
|
|
|
|
* Get the offset between the coordinate systems of |this| and aOther
|
|
|
|
* expressed in appunits per dev pixel of |this|' document. Adding the return
|
|
|
|
* value to a point that is relative to the origin of |this| will make the
|
|
|
|
* point relative to the origin of aOther but in the appunits per dev pixel
|
|
|
|
* ratio of |this|.
|
|
|
|
*
|
|
|
|
* aOther must be non-null.
|
|
|
|
*
|
|
|
|
* This function is fastest when aOther is an ancestor of |this|.
|
|
|
|
*
|
|
|
|
* This function works across document boundaries.
|
|
|
|
*
|
|
|
|
* Because this function may cross document boundaries that have different
|
|
|
|
* app units per dev pixel ratios it needs to be used very carefully.
|
|
|
|
*
|
|
|
|
* NOTE: this actually returns the offset from aOther to |this|, but
|
|
|
|
* that offset is added to transform _coordinates_ from |this| to
|
|
|
|
* aOther.
|
|
|
|
*/
|
|
|
|
nsPoint GetOffsetToCrossDoc(const nsIFrame* aOther) const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2008-06-15 18:26:41 -07:00
|
|
|
* Get the screen rect of the frame in pixels.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return the pixel rect of the frame in screen coordinates.
|
|
|
|
*/
|
|
|
|
nsIntRect GetScreenRect() const;
|
|
|
|
virtual nsIntRect GetScreenRectExternal() const;
|
|
|
|
|
2008-06-15 18:26:41 -07:00
|
|
|
/**
|
|
|
|
* Get the screen rect of the frame in app units.
|
|
|
|
* @return the app unit rect of the frame in screen coordinates.
|
|
|
|
*/
|
|
|
|
nsRect GetScreenRectInAppUnits() const;
|
|
|
|
virtual nsRect GetScreenRectInAppUnitsExternal() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Returns the offset from this frame to the closest geometric parent that
|
|
|
|
* has a view. Also returns the containing view or null in case of error
|
|
|
|
*/
|
2013-11-11 23:57:44 -08:00
|
|
|
void GetOffsetFromView(nsPoint& aOffset, nsView** aView) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2010-07-02 12:11:04 -07:00
|
|
|
* Returns the nearest widget containing this frame. If this frame has a
|
|
|
|
* view and the view has a widget, then this frame's widget is
|
2007-03-22 10:30:00 -07:00
|
|
|
* returned, otherwise this frame's geometric parent is checked
|
|
|
|
* recursively upwards.
|
|
|
|
* XXX virtual because gfx callers use it! (themes)
|
|
|
|
*/
|
2010-07-02 12:11:04 -07:00
|
|
|
virtual nsIWidget* GetNearestWidget() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-14 15:52:07 -07:00
|
|
|
/**
|
2010-07-02 12:11:04 -07:00
|
|
|
* Same as GetNearestWidget() above but uses an outparam to return the offset
|
|
|
|
* of this frame to the returned widget expressed in appunits of |this| (the
|
|
|
|
* widget might be in a different document with a different zoom).
|
2010-03-14 15:52:07 -07:00
|
|
|
*/
|
2010-07-02 12:11:04 -07:00
|
|
|
virtual nsIWidget* GetNearestWidget(nsPoint& aOffset) const;
|
2010-03-14 15:52:07 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2013-10-08 11:47:21 -07:00
|
|
|
* Get the "type" of the frame. May return nullptr.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @see nsGkAtoms
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* GetType() const = 0;
|
2008-09-13 02:42:11 -07:00
|
|
|
|
|
|
|
/**
|
2011-12-27 19:24:18 -08:00
|
|
|
* Returns a transformation matrix that converts points in this frame's
|
|
|
|
* coordinate space to points in some ancestor frame's coordinate space.
|
|
|
|
* The frame decides which ancestor it will use as a reference point.
|
|
|
|
* If this frame has no ancestor, aOutAncestor will be set to null.
|
|
|
|
*
|
|
|
|
* @param aStopAtAncestor don't look further than aStopAtAncestor. If null,
|
|
|
|
* all ancestors (including across documents) will be traversed.
|
|
|
|
* @param aOutAncestor [out] The ancestor frame the frame has chosen. If
|
2012-06-21 22:06:49 -07:00
|
|
|
* this frame has no ancestor, *aOutAncestor will be set to null. If
|
|
|
|
* this frame is not a root frame, then *aOutAncestor will be in the same
|
|
|
|
* document as this frame. If this frame IsTransformed(), then *aOutAncestor
|
|
|
|
* will be the parent frame (if not preserve-3d) or the nearest non-transformed
|
|
|
|
* ancestor (if preserve-3d).
|
2011-12-27 19:24:18 -08:00
|
|
|
* @return A gfxMatrix that converts points in this frame's coordinate space
|
|
|
|
* into points in aOutAncestor's coordinate space.
|
|
|
|
*/
|
2012-09-12 17:32:53 -07:00
|
|
|
gfx3DMatrix GetTransformMatrix(const nsIFrame* aStopAtAncestor,
|
2012-05-16 21:05:09 -07:00
|
|
|
nsIFrame **aOutAncestor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Bit-flags to pass to IsFrameOfType()
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
eMathML = 1 << 0,
|
|
|
|
eSVG = 1 << 1,
|
|
|
|
eSVGForeignObject = 1 << 2,
|
2008-09-30 17:51:05 -07:00
|
|
|
eSVGContainer = 1 << 3,
|
2010-07-01 09:40:19 -07:00
|
|
|
eSVGGeometry = 1 << 4,
|
|
|
|
eSVGPaintServer = 1 << 5,
|
|
|
|
eBidiInlineContainer = 1 << 6,
|
2007-03-22 10:30:00 -07:00
|
|
|
// the frame is for a replaced element, such as an image
|
2010-07-01 09:40:19 -07:00
|
|
|
eReplaced = 1 << 7,
|
2007-03-22 10:30:00 -07:00
|
|
|
// Frame that contains a block but looks like a replaced element
|
|
|
|
// from the outside
|
2010-07-01 09:40:19 -07:00
|
|
|
eReplacedContainsBlock = 1 << 8,
|
2007-05-17 23:04:04 -07:00
|
|
|
// A frame that participates in inline reflow, i.e., one that
|
|
|
|
// requires nsHTMLReflowState::mLineLayout.
|
2010-07-01 09:40:19 -07:00
|
|
|
eLineParticipant = 1 << 9,
|
|
|
|
eXULBox = 1 << 10,
|
|
|
|
eCanContainOverflowContainers = 1 << 11,
|
|
|
|
eBlockFrame = 1 << 12,
|
2013-03-07 18:18:45 -08:00
|
|
|
eTablePart = 1 << 13,
|
2008-07-13 15:41:18 -07:00
|
|
|
// If this bit is set, the frame doesn't allow ignorable whitespace as
|
|
|
|
// children. For example, the whitespace between <table>\n<tr>\n<td>
|
|
|
|
// will be excluded during the construction of children.
|
2013-03-07 18:18:45 -08:00
|
|
|
eExcludesIgnorableWhitespace = 1 << 14,
|
|
|
|
eSupportsCSSTransforms = 1 << 15,
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// These are to allow nsFrame::Init to assert that IsFrameOfType
|
|
|
|
// implementations all call the base class method. They are only
|
|
|
|
// meaningful in DEBUG builds.
|
|
|
|
eDEBUGAllFrames = 1 << 30,
|
|
|
|
eDEBUGNoFrames = 1 << 31
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* API for doing a quick check if a frame is of a given
|
|
|
|
* type. Returns true if the frame matches ALL flags passed in.
|
|
|
|
*
|
|
|
|
* Implementations should always override with inline virtual
|
|
|
|
* functions that call the base class's IsFrameOfType method.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2012-12-03 20:50:05 -08:00
|
|
|
return !(aFlags & ~(nsIFrame::eDEBUGAllFrames | nsIFrame::eSupportsCSSTransforms));
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2012-12-03 20:50:05 -08:00
|
|
|
return !(aFlags & ~nsIFrame::eSupportsCSSTransforms);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-05-11 21:04:30 -07:00
|
|
|
* Returns true if the frame is a block wrapper.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-05-11 21:04:30 -07:00
|
|
|
bool IsBlockWrapper() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get this frame's CSS containing block.
|
|
|
|
*
|
|
|
|
* The algorithm is defined in
|
|
|
|
* http://www.w3.org/TR/CSS2/visudet.html#containing-block-details.
|
2013-02-16 10:34:34 -08:00
|
|
|
*
|
|
|
|
* NOTE: This is guaranteed to return a non-null pointer when invoked on any
|
|
|
|
* frame other than the root frame.
|
2011-05-11 21:04:30 -07:00
|
|
|
*/
|
|
|
|
nsIFrame* GetContainingBlock() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this frame a containing block for floating elements?
|
|
|
|
* Note that very few frames are, so default to false.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsFloatContainingBlock() const { return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this a leaf frame? Frames that want the frame constructor to be able
|
|
|
|
* to construct kids for them should return false, all others should return
|
|
|
|
* true. Note that returning true here does not mean that the frame _can't_
|
|
|
|
* have kids. It could still have kids created via
|
|
|
|
* nsIAnonymousContentCreator. Returning true indicates that "normal"
|
|
|
|
* (non-anonymous, XBL-bound, CSS generated content, etc) children should not
|
|
|
|
* be constructed.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsLeaf() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
/**
|
|
|
|
* Marks all display items created by this frame as needing a repaint,
|
2012-08-28 22:48:44 -07:00
|
|
|
* and calls SchedulePaint() if requested and one is not already pending.
|
2012-08-28 22:39:01 -07:00
|
|
|
*
|
|
|
|
* This includes all display items created by this frame, including
|
|
|
|
* container types.
|
2012-09-25 16:59:56 -07:00
|
|
|
*
|
|
|
|
* @param aDisplayItemKey If specified, only issues an invalidate
|
|
|
|
* if this frame painted a display item of that type during the
|
|
|
|
* previous paint. SVG rendering observers are always notified.
|
2012-08-28 22:39:01 -07:00
|
|
|
*/
|
2012-09-25 16:59:56 -07:00
|
|
|
virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0);
|
2012-08-28 22:48:45 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as InvalidateFrame(), but only mark a fixed rect as needing
|
|
|
|
* repainting.
|
|
|
|
*
|
|
|
|
* @param aRect The rect to invalidate, relative to the TopLeft of the
|
|
|
|
* frame's border box.
|
2012-09-25 16:59:56 -07:00
|
|
|
* @param aDisplayItemKey If specified, only issues an invalidate
|
|
|
|
* if this frame painted a display item of that type during the
|
|
|
|
* previous paint. SVG rendering observers are always notified.
|
2012-08-28 22:48:45 -07:00
|
|
|
*/
|
2012-09-25 16:59:56 -07:00
|
|
|
virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0);
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls InvalidateFrame() on all frames descendant frames (including
|
|
|
|
* this one).
|
|
|
|
*
|
|
|
|
* This function doesn't walk through placeholder frames to invalidate
|
|
|
|
* the out-of-flow frames.
|
2012-09-25 16:59:56 -07:00
|
|
|
*
|
|
|
|
* @param aDisplayItemKey If specified, only issues an invalidate
|
|
|
|
* if this frame painted a display item of that type during the
|
|
|
|
* previous paint. SVG rendering observers are always notified.
|
2012-08-28 22:39:01 -07:00
|
|
|
*/
|
2012-09-25 16:59:56 -07:00
|
|
|
void InvalidateFrameSubtree(uint32_t aDisplayItemKey = 0);
|
2012-08-28 22:48:45 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a frame is about to be removed and needs to be invalidated.
|
|
|
|
* Normally does nothing since DLBI handles removed frames.
|
|
|
|
*/
|
|
|
|
virtual void InvalidateFrameForRemoval() {}
|
2012-10-02 22:55:50 -07:00
|
|
|
|
2012-10-02 22:55:52 -07:00
|
|
|
/**
|
|
|
|
* When HasUserData(frame->LayerIsPrerenderedDataKey()), then the
|
|
|
|
* entire overflow area of this frame has been rendered in its
|
|
|
|
* layer(s).
|
|
|
|
*/
|
|
|
|
static void* LayerIsPrerenderedDataKey() {
|
|
|
|
return &sLayerIsPrerenderedDataKey;
|
|
|
|
}
|
|
|
|
static uint8_t sLayerIsPrerenderedDataKey;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to update this frame's transform without invalidating any
|
|
|
|
* content. Return true iff successful. If unsuccessful, the
|
|
|
|
* caller is responsible for scheduling an invalidating paint.
|
|
|
|
*/
|
|
|
|
bool TryUpdateTransformOnly();
|
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
/**
|
|
|
|
* Checks if a frame has had InvalidateFrame() called on it since the
|
|
|
|
* last paint.
|
2012-08-28 22:48:45 -07:00
|
|
|
*
|
|
|
|
* If true, then the invalid rect is returned in aRect, with an
|
|
|
|
* empty rect meaning all pixels drawn by this frame should be
|
|
|
|
* invalidated.
|
|
|
|
* If false, aRect is left unchanged.
|
2012-08-28 22:39:01 -07:00
|
|
|
*/
|
2012-08-28 22:48:45 -07:00
|
|
|
bool IsInvalid(nsRect& aRect);
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if any frame within the frame subtree (including this frame)
|
|
|
|
* returns true for IsInvalid().
|
|
|
|
*/
|
|
|
|
bool HasInvalidFrameInSubtree()
|
|
|
|
{
|
|
|
|
return HasAnyStateBits(NS_FRAME_NEEDS_PAINT | NS_FRAME_DESCENDANT_NEEDS_PAINT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the invalid state from the current frame and all
|
|
|
|
* descendant frames.
|
|
|
|
*/
|
|
|
|
void ClearInvalidationStateBits();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that the refresh driver is running, and schedules a view
|
|
|
|
* manager flush on the next tick.
|
|
|
|
*
|
|
|
|
* The view manager flush will update the layer tree, repaint any
|
|
|
|
* invalid areas in the layer tree and schedule a layer tree
|
|
|
|
* composite operation to display the layer tree.
|
2012-08-28 22:48:15 -07:00
|
|
|
*
|
2013-05-23 00:04:21 -07:00
|
|
|
* In general it is not necessary for frames to call this when they change.
|
|
|
|
* For example, changes that result in a reflow will have this called for
|
|
|
|
* them by PresContext::DoReflow when the reflow begins. Style changes that
|
|
|
|
* do not trigger a reflow should have this called for them by
|
|
|
|
* DoApplyRenderingChangeToTree.
|
|
|
|
*
|
2012-08-28 22:48:15 -07:00
|
|
|
* @param aFlags PAINT_COMPOSITE_ONLY : No changes have been made
|
|
|
|
* that require a layer tree update, so only schedule a layer
|
|
|
|
* tree composite.
|
2012-08-28 22:39:01 -07:00
|
|
|
*/
|
2012-08-28 22:48:15 -07:00
|
|
|
enum {
|
2012-09-30 21:29:02 -07:00
|
|
|
PAINT_DEFAULT = 0,
|
|
|
|
PAINT_COMPOSITE_ONLY = 1 << 0
|
2012-08-28 22:48:15 -07:00
|
|
|
};
|
2012-09-30 21:29:02 -07:00
|
|
|
void SchedulePaint(uint32_t aFlags = PAINT_DEFAULT);
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the layer tree includes a dedicated layer for this
|
|
|
|
* frame/display item key pair, and invalidates at least aDamageRect
|
|
|
|
* area within that layer.
|
|
|
|
*
|
|
|
|
* If no layer is found, calls InvalidateFrame() instead.
|
|
|
|
*
|
|
|
|
* @param aDamageRect Area of the layer to invalidate.
|
|
|
|
* @param aDisplayItemKey Display item type.
|
2013-10-01 20:05:49 -07:00
|
|
|
* @param aFlags UPDATE_IS_ASYNC : Will skip the invalidation
|
|
|
|
* if the found layer is being composited by a remote
|
|
|
|
* compositor.
|
2012-08-28 22:39:01 -07:00
|
|
|
* @return Layer, if found, nullptr otherwise.
|
|
|
|
*/
|
2013-10-01 20:05:49 -07:00
|
|
|
enum {
|
|
|
|
UPDATE_IS_ASYNC = 1 << 0
|
|
|
|
};
|
|
|
|
Layer* InvalidateLayer(uint32_t aDisplayItemKey, const nsIntRect* aDamageRect = nullptr, uint32_t aFlags = 0);
|
2012-08-28 22:39:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2010-10-06 21:25:45 -07:00
|
|
|
* Returns a rect that encompasses everything that might be painted by
|
2007-03-26 20:58:17 -07:00
|
|
|
* this frame. This includes this frame, all its descendent frames, this
|
|
|
|
* frame's outline, and descentant frames' outline, but does not include
|
|
|
|
* areas clipped out by the CSS "overflow" and "clip" properties.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2011-10-17 07:59:28 -07:00
|
|
|
* HasOverflowRects() (below) will return true when this overflow
|
2010-10-06 21:25:45 -07:00
|
|
|
* rect has been explicitly set, even if it matches mRect.
|
2008-02-19 23:08:55 -08:00
|
|
|
* XXX Note: because of a space optimization using the formula above,
|
|
|
|
* during reflow this function does not give accurate data if
|
|
|
|
* FinishAndStoreOverflow has been called but mRect hasn't yet been
|
2010-10-06 21:25:45 -07:00
|
|
|
* updated yet. FIXME: This actually isn't true, but it should be.
|
|
|
|
*
|
|
|
|
* The visual overflow rect should NEVER be used for things that
|
|
|
|
* affect layout. The scrollable overflow rect is permitted to affect
|
|
|
|
* layout.
|
2008-02-19 23:08:55 -08:00
|
|
|
*
|
2008-09-15 18:51:52 -07:00
|
|
|
* @return the rect relative to this frame's origin, but after
|
|
|
|
* CSS transforms have been applied (i.e. not really this frame's coordinate
|
|
|
|
* system, and may not contain the frame's border-box, e.g. if there
|
|
|
|
* is a CSS transform scaling it down)
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect GetVisualOverflowRect() const {
|
|
|
|
return GetOverflowRect(eVisualOverflow);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-15 18:51:52 -07:00
|
|
|
/**
|
2010-10-06 21:25:45 -07:00
|
|
|
* Returns a rect that encompasses the area of this frame that the
|
|
|
|
* user should be able to scroll to reach. This is similar to
|
|
|
|
* GetVisualOverflowRect, but does not include outline or shadows, and
|
|
|
|
* may in the future include more margins than visual overflow does.
|
|
|
|
* It does not include areas clipped out by the CSS "overflow" and
|
|
|
|
* "clip" properties.
|
2008-09-15 18:51:52 -07:00
|
|
|
*
|
2011-10-17 07:59:28 -07:00
|
|
|
* HasOverflowRects() (below) will return true when this overflow
|
2010-10-06 21:25:45 -07:00
|
|
|
* rect has been explicitly set, even if it matches mRect.
|
2008-09-15 18:51:52 -07:00
|
|
|
* XXX Note: because of a space optimization using the formula above,
|
|
|
|
* during reflow this function does not give accurate data if
|
|
|
|
* FinishAndStoreOverflow has been called but mRect hasn't yet been
|
|
|
|
* updated yet.
|
|
|
|
*
|
2010-10-06 21:25:45 -07:00
|
|
|
* @return the rect relative to this frame's origin, but after
|
|
|
|
* CSS transforms have been applied (i.e. not really this frame's coordinate
|
|
|
|
* system, and may not contain the frame's border-box, e.g. if there
|
|
|
|
* is a CSS transform scaling it down)
|
|
|
|
*/
|
|
|
|
nsRect GetScrollableOverflowRect() const {
|
|
|
|
return GetOverflowRect(eScrollableOverflow);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect GetOverflowRect(nsOverflowType aType) const;
|
|
|
|
|
|
|
|
nsOverflowAreas GetOverflowAreas() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as GetScrollableOverflowRect, except relative to the parent
|
|
|
|
* frame.
|
|
|
|
*
|
2008-09-15 18:51:52 -07:00
|
|
|
* @return the rect relative to the parent frame, in the parent frame's
|
|
|
|
* coordinate system
|
|
|
|
*/
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect GetScrollableOverflowRectRelativeToParent() const;
|
2008-09-15 18:51:52 -07:00
|
|
|
|
|
|
|
/**
|
2010-10-06 21:25:45 -07:00
|
|
|
* Like GetVisualOverflowRect, except in this frame's
|
|
|
|
* coordinate system (before transforms are applied).
|
2008-09-15 18:51:52 -07:00
|
|
|
*
|
|
|
|
* @return the rect relative to this frame, before any CSS transforms have
|
|
|
|
* been applied, i.e. in this frame's coordinate system
|
|
|
|
*/
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect GetVisualOverflowRectRelativeToSelf() const;
|
2008-09-15 18:51:52 -07:00
|
|
|
|
2012-06-26 03:49:23 -07:00
|
|
|
/**
|
|
|
|
* Returns this frame's visual overflow rect as it would be before taking
|
|
|
|
* account of SVG effects or transforms. The rect returned is relative to
|
|
|
|
* this frame.
|
|
|
|
*/
|
|
|
|
nsRect GetPreEffectsVisualOverflowRect() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2010-10-06 21:25:45 -07:00
|
|
|
* Store the overflow area in the frame's mOverflow.mVisualDeltas
|
|
|
|
* fields or as a frame property in the frame manager so that it can
|
2011-12-05 04:38:46 -08:00
|
|
|
* be retrieved later without reflowing the frame. Returns true if either of
|
|
|
|
* the overflow areas changed.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-12-05 04:38:46 -08:00
|
|
|
bool FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
|
2012-10-31 18:25:45 -07:00
|
|
|
nsSize aNewSize, nsSize* aOldSize = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-05 04:38:46 -08:00
|
|
|
bool FinishAndStoreOverflow(nsHTMLReflowMetrics* aMetrics) {
|
|
|
|
return FinishAndStoreOverflow(aMetrics->mOverflowAreas,
|
2013-12-27 09:59:52 -08:00
|
|
|
nsSize(aMetrics->Width(), aMetrics->Height()));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-04-05 17:31:50 -07:00
|
|
|
/**
|
|
|
|
* Returns whether the frame has an overflow rect that is different from
|
|
|
|
* its border-box.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasOverflowAreas() const {
|
2009-04-05 17:31:50 -07:00
|
|
|
return mOverflow.mType != NS_FRAME_OVERFLOW_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-10-06 21:25:45 -07:00
|
|
|
* Removes any stored overflow rects (visual and scrollable) from the frame.
|
2011-12-05 04:38:46 -08:00
|
|
|
* Returns true if the overflow changed.
|
2009-04-05 17:31:50 -07:00
|
|
|
*/
|
2011-12-05 04:38:46 -08:00
|
|
|
bool ClearOverflowRects();
|
2009-04-05 17:31:50 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Determine whether borders should not be painted on certain sides of the
|
|
|
|
* frame.
|
2013-07-25 08:34:27 -07:00
|
|
|
*
|
2013-09-12 11:28:46 -07:00
|
|
|
* @note (See also bug 743402, comment 11) GetSkipSides() and its sister
|
2013-07-25 08:34:27 -07:00
|
|
|
* method, ApplySkipSides() checks to see if this frame has a previous
|
|
|
|
* or next continuation to determine if a side should be skipped.
|
|
|
|
* Unfortunately, this only works after reflow has been completed. In
|
|
|
|
* lieu of this, during reflow, an nsHTMLReflowState parameter can be
|
|
|
|
* passed in, indicating that it should be used to determine if sides
|
|
|
|
* should be skipped during reflow.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-07-25 08:34:27 -07:00
|
|
|
virtual int GetSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const { return 0; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-20 01:15:41 -08:00
|
|
|
/**
|
|
|
|
* @returns true if this frame is selected.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-08-23 15:15:45 -07:00
|
|
|
bool IsSelected() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* called to discover where this frame, or a parent frame has user-select style
|
|
|
|
* applied, which affects that way that it is selected.
|
|
|
|
*
|
|
|
|
* @param aIsSelectable out param. Set to true if the frame can be selected
|
|
|
|
* (i.e. is not affected by user-select: none)
|
|
|
|
* @param aSelectStyle out param. Returns the type of selection style found
|
|
|
|
* (using values defined in nsStyleConsts.h).
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD IsSelectable(bool* aIsSelectable, uint8_t* aSelectStyle) const = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to retrieve the SelectionController associated with the frame.
|
|
|
|
* @param aSelCon will contain the selection controller associated with
|
|
|
|
* the frame.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon) = 0;
|
|
|
|
|
|
|
|
/**
|
2007-11-22 12:47:33 -08:00
|
|
|
* Call to get nsFrameSelection for this frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-11-22 12:47:33 -08:00
|
|
|
already_AddRefed<nsFrameSelection> GetFrameSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetConstFrameSelection returns an object which methods are safe to use for
|
|
|
|
* example in nsIFrame code.
|
|
|
|
*/
|
2011-12-20 01:15:41 -08:00
|
|
|
const nsFrameSelection* GetConstFrameSelection() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* called to find the previous/next character, word, or line returns the actual
|
|
|
|
* nsIFrame and the frame offset. THIS DOES NOT CHANGE SELECTION STATE
|
|
|
|
* uses frame's begin selection state to start. if no selection on this frame will
|
|
|
|
* return NS_ERROR_FAILURE
|
|
|
|
* @param aPOS is defined in nsFrameSelection
|
|
|
|
*/
|
|
|
|
NS_IMETHOD PeekOffset(nsPeekOffsetStruct *aPos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* called to find the previous/next selectable leaf frame.
|
|
|
|
* @param aDirection [in] the direction to move in (eDirPrevious or eDirNext)
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aVisual [in] whether bidi caret behavior is visual (true) or logical (false)
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aJumpLines [in] whether to allow jumping across line boundaries
|
|
|
|
* @param aScrollViewStop [in] whether to stop when reaching a scroll frame boundary
|
|
|
|
* @param aOutFrame [out] the previous/next selectable leaf frame
|
|
|
|
* @param aOutOffset [out] 0 indicates that we arrived at the beginning of the output frame;
|
|
|
|
* -1 indicates that we arrived at its end.
|
|
|
|
* @param aOutJumpedLine [out] whether this frame and the returned frame are on different lines
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult GetFrameFromDirection(nsDirection aDirection, bool aVisual,
|
|
|
|
bool aJumpLines, bool aScrollViewStop,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIFrame** aOutFrame, int32_t* aOutOffset, bool* aOutJumpedLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* called to see if the children of the frame are visible from indexstart to index end.
|
2011-10-17 07:59:28 -07:00
|
|
|
* this does not change any state. returns true only if the indexes are valid and any of
|
2007-03-22 10:30:00 -07:00
|
|
|
* the children are visible. for textframes this index is the character index.
|
2011-10-17 07:59:28 -07:00
|
|
|
* if aStart = aEnd result will be false
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aStart start index of first child from 0-N (number of children)
|
|
|
|
* @param aEnd end index of last child from 0-N
|
|
|
|
* @param aRecurse should this frame talk to siblings to get to the contents other children?
|
|
|
|
* @param aFinished did this frame have the aEndIndex? or is there more work to do
|
|
|
|
* @param _retval return value true or false. false = range is not rendered.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD CheckVisibility(nsPresContext* aContext, int32_t aStartIndex, int32_t aEndIndex, bool aRecurse, bool *aFinished, bool *_retval)=0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to tell a frame that one of its child frames is dirty (i.e.,
|
|
|
|
* has the NS_FRAME_IS_DIRTY *or* NS_FRAME_HAS_DIRTY_CHILDREN bit
|
|
|
|
* set). This should always set the NS_FRAME_HAS_DIRTY_CHILDREN on
|
|
|
|
* the frame, and may do other work.
|
|
|
|
*/
|
|
|
|
virtual void ChildIsDirty(nsIFrame* aChild) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to retrieve this frame's accessible.
|
|
|
|
* If this frame implements Accessibility return a valid accessible
|
|
|
|
* If not return NS_ERROR_NOT_IMPLEMENTED.
|
2012-05-28 18:18:45 -07:00
|
|
|
* Note: Accessible must be refcountable. Do not implement directly on your frame
|
2007-03-22 10:30:00 -07:00
|
|
|
* Use a mediatior of some kind.
|
|
|
|
*/
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the frame whose style context should be the parent of this
|
|
|
|
* frame's style context (i.e., provide the parent style context).
|
|
|
|
* This frame must either be an ancestor of this frame or a child. If
|
2012-03-12 20:54:15 -07:00
|
|
|
* this returns a child frame, then the child frame must be sure to
|
|
|
|
* return a grandparent or higher! Furthermore, if a child frame is
|
|
|
|
* returned it must have the same GetContent() as this frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2011-09-12 09:08:07 -07:00
|
|
|
* @return The frame whose style context should be the parent of this frame's
|
|
|
|
* style context. Null is permitted, and means that this frame's
|
|
|
|
* style context should be the root of the style context tree.
|
|
|
|
*/
|
2012-02-15 01:28:21 -08:00
|
|
|
virtual nsIFrame* GetParentStyleContextFrame() const = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether a frame is visible for painting;
|
|
|
|
* taking into account whether it is painting a selection or printing.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisibleForPainting(nsDisplayListBuilder* aBuilder);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Determines whether a frame is visible for painting or collapsed;
|
|
|
|
* taking into account whether it is painting a selection or printing,
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisibleOrCollapsedForPainting(nsDisplayListBuilder* aBuilder);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* As above, but slower because we have to recompute some stuff that
|
|
|
|
* aBuilder already has.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisibleForPainting();
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Check whether this frame is visible in the current selection. Returns
|
2011-10-17 07:59:28 -07:00
|
|
|
* true if there is no current selection.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisibleInSelection(nsDisplayListBuilder* aBuilder);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Overridable function to determine whether this frame should be considered
|
|
|
|
* "in" the given non-null aSelection for visibility purposes.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsVisibleInSelection(nsISelection* aSelection);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether this frame is a pseudo stacking context, looking
|
|
|
|
* only as style --- i.e., assuming that it's in-flow and not a replaced
|
2012-07-20 11:12:29 -07:00
|
|
|
* element and not an SVG element.
|
|
|
|
* XXX maybe check IsTransformed()?
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-10-01 14:00:38 -07:00
|
|
|
bool IsPseudoStackingContextFromStyle();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool HonorPrintBackgroundSettings() { return true; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the frame is logically empty, which is roughly
|
|
|
|
* whether the layout would be the same whether or not the frame is
|
|
|
|
* present. Placeholder frames should return true. Block frames
|
|
|
|
* should be considered empty whenever margins collapse through them,
|
|
|
|
* even though those margins are relevant. Text frames containing
|
|
|
|
* only whitespace that does not contribute to the height of the line
|
|
|
|
* should return true.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsEmpty() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Return the same as IsEmpty(). This may only be called after the frame
|
|
|
|
* has been reflowed and before any further style or content changes.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool CachedIsEmpty();
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Determine whether the frame is logically empty, assuming that all
|
|
|
|
* its children are empty.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsSelfEmpty() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IsGeneratedContentFrame returns whether a frame corresponds to
|
|
|
|
* generated content
|
|
|
|
*
|
|
|
|
* @return whether the frame correspods to generated content
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsGeneratedContentFrame() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return (mState & NS_FRAME_GENERATED_CONTENT) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsPseudoFrame returns whether a frame is a pseudo frame (eg an
|
|
|
|
* anonymous table-row frame created for a CSS table-cell without an
|
|
|
|
* enclosing table-row.
|
|
|
|
*
|
|
|
|
* @param aParentContent the content node corresponding to the parent frame
|
|
|
|
* @return whether the frame is a pseudo frame
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPseudoFrame(nsIContent* aParentContent) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mContent == aParentContent;
|
|
|
|
}
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
FrameProperties Properties() const {
|
|
|
|
return FrameProperties(PresContext()->PropertyTable(), this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(BaseLevelProperty, nullptr)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(EmbeddingLevelProperty, nullptr)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(ParagraphDepthProperty, nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_GET_BASE_LEVEL(frame) \
|
2010-03-28 18:46:55 -07:00
|
|
|
NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::BaseLevelProperty()))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_GET_EMBEDDING_LEVEL(frame) \
|
2010-03-28 18:46:55 -07:00
|
|
|
NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::EmbeddingLevelProperty()))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-11 11:26:02 -08:00
|
|
|
#define NS_GET_PARAGRAPH_DEPTH(frame) \
|
|
|
|
NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* Return true if and only if this frame obeys visibility:hidden.
|
2007-03-22 10:30:00 -07:00
|
|
|
* if it does not, then nsContainerFrame will hide its view even though
|
|
|
|
* this means children can't be made visible again.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool SupportsVisibilityHidden() { return true; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2012-03-02 00:28:56 -08:00
|
|
|
* Returns true if the frame has a valid clip rect set via the 'clip'
|
|
|
|
* property, and the 'clip' property applies to this frame. The 'clip'
|
|
|
|
* property applies to HTML frames if they are absolutely positioned. The
|
|
|
|
* 'clip' property applies to SVG frames regardless of the value of the
|
|
|
|
* 'position' property.
|
|
|
|
*
|
|
|
|
* If this method returns true, then we also set aRect to the computed clip
|
|
|
|
* rect, with coordinates relative to this frame's origin. aRect must not be
|
|
|
|
* null!
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-03-02 00:28:56 -08:00
|
|
|
bool GetClipPropClipRect(const nsStyleDisplay* aDisp, nsRect* aRect,
|
2011-08-26 17:01:46 -07:00
|
|
|
const nsSize& aSize) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if this frame is focusable and in the current tab order.
|
|
|
|
* Tabbable is indicated by a nonnegative tabindex & is a subset of focusable.
|
|
|
|
* For example, only the selected radio button in a group is in the
|
|
|
|
* tab order, unless the radio group has no selection in which case
|
|
|
|
* all of the visible, non-disabled radio buttons in the group are
|
|
|
|
* in the tab order. On the other hand, all of the visible, non-disabled
|
|
|
|
* radio buttons are always focusable via clicking or script.
|
|
|
|
* Also, depending on the pref accessibility.tabfocus some widgets may be
|
|
|
|
* focusable but removed from the tab order. This is the default on
|
|
|
|
* Mac OS X, where fewer items are focusable.
|
|
|
|
* @param [in, optional] aTabIndex the computed tab index
|
|
|
|
* < 0 if not tabbable
|
|
|
|
* == 0 if in normal tab order
|
|
|
|
* > 0 can be tabbed to in the order specified by this value
|
|
|
|
* @param [in, optional] aWithMouse, is this focus query for mouse clicking
|
|
|
|
* @return whether the frame is focusable via mouse, kbd or script.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsFocusable(int32_t *aTabIndex = nullptr, bool aWithMouse = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// BOX LAYOUT METHODS
|
|
|
|
// These methods have been migrated from nsIBox and are in the process of
|
|
|
|
// being refactored. DO NOT USE OUTSIDE OF XUL.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsBoxFrame() const
|
2007-07-03 15:11:28 -07:00
|
|
|
{
|
|
|
|
return IsFrameOfType(nsIFrame::eXULBox);
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsBoxWrapped() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{ return (!IsBoxFrame() && mParent && mParent->IsBoxFrame()); }
|
|
|
|
|
|
|
|
enum Halignment {
|
|
|
|
hAlign_Left,
|
|
|
|
hAlign_Right,
|
|
|
|
hAlign_Center
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Valignment {
|
|
|
|
vAlign_Top,
|
|
|
|
vAlign_Middle,
|
|
|
|
vAlign_BaseLine,
|
|
|
|
vAlign_Bottom
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This calculates the minimum size required for a box based on its state
|
|
|
|
* @param[in] aBoxLayoutState The desired state to calculate for
|
|
|
|
* @return The minimum size
|
|
|
|
*/
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This calculates the preferred size of a box based on its state
|
|
|
|
* @param[in] aBoxLayoutState The desired state to calculate for
|
|
|
|
* @return The preferred size
|
|
|
|
*/
|
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This calculates the maximum size for a box based on its state
|
|
|
|
* @param[in] aBoxLayoutState The desired state to calculate for
|
|
|
|
* @return The maximum size
|
|
|
|
*/
|
|
|
|
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This returns the minimum size for the scroll area if this frame is
|
|
|
|
* being scrolled. Usually it's (0,0).
|
|
|
|
*/
|
|
|
|
virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) = 0;
|
|
|
|
|
|
|
|
// Implemented in nsBox, used in nsBoxFrame
|
2012-11-30 15:25:32 -08:00
|
|
|
uint32_t GetOrdinal();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) = 0;
|
|
|
|
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) = 0;
|
2011-06-15 14:03:49 -07:00
|
|
|
virtual bool IsCollapsed() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
// This does not alter the overflow area. If the caller is changing
|
|
|
|
// the box size, the caller is responsible for updating the overflow
|
|
|
|
// area. It's enough to just call Layout or SyncLayout on the
|
2011-10-17 07:59:28 -07:00
|
|
|
// box. You can pass true to aRemoveOverflowArea as a
|
2007-03-22 10:30:00 -07:00
|
|
|
// convenience.
|
|
|
|
virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRemoveOverflowAreas = false) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_HIDDEN_(nsresult) Layout(nsBoxLayoutState& aBoxLayoutState);
|
2012-08-05 20:00:57 -07:00
|
|
|
nsIFrame* GetChildBox() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// box layout ends at box-wrapped frames, so don't allow these frames
|
|
|
|
// to report child boxes.
|
2012-07-30 07:20:58 -07:00
|
|
|
return IsBoxFrame() ? GetFirstPrincipalChild() : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-08-05 20:00:57 -07:00
|
|
|
nsIFrame* GetNextBox() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return (mParent && mParent->IsBoxFrame()) ? mNextSibling : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-08-05 20:00:57 -07:00
|
|
|
nsIFrame* GetParentBox() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return (mParent && mParent->IsBoxFrame()) ? mParent : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// Box methods. Note that these do NOT just get the CSS border, padding,
|
|
|
|
// etc. They also talk to nsITheme.
|
|
|
|
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
|
|
|
|
NS_IMETHOD GetBorder(nsMargin& aBorder)=0;
|
|
|
|
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding)=0;
|
|
|
|
NS_IMETHOD GetMargin(nsMargin& aMargin)=0;
|
2011-07-11 07:05:10 -07:00
|
|
|
virtual void SetLayoutManager(nsBoxLayout* aLayout) { }
|
2012-07-30 07:20:58 -07:00
|
|
|
virtual nsBoxLayout* GetLayoutManager() { return nullptr; }
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_HIDDEN_(nsresult) GetClientRect(nsRect& aContentRect);
|
|
|
|
|
|
|
|
// For nsSprocketLayout
|
|
|
|
virtual Valignment GetVAlign() const = 0;
|
|
|
|
virtual Halignment GetHAlign() const = 0;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsHorizontal() const { return (mState & NS_STATE_IS_HORIZONTAL) != 0; }
|
|
|
|
bool IsNormalDirection() const { return (mState & NS_STATE_IS_DIRECTION_NORMAL) != 0; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-28 22:39:31 -07:00
|
|
|
NS_HIDDEN_(nsresult) Redraw(nsBoxLayoutState& aState);
|
2012-08-05 20:00:57 -07:00
|
|
|
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild)=0;
|
2010-11-30 06:59:46 -08:00
|
|
|
// XXX take this out after we've branched
|
2012-07-14 21:14:06 -07:00
|
|
|
virtual bool GetMouseThrough() const { return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, bool aDebug)=0;
|
|
|
|
NS_IMETHOD GetDebug(bool& aDebug)=0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD DumpBox(FILE* out)=0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if this text frame ends with a newline character. It
|
|
|
|
* should return false if this is not a text frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2014-01-02 13:22:12 -08:00
|
|
|
virtual bool HasSignificantTerminalNewline() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-05 20:00:57 -07:00
|
|
|
static bool AddCSSPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
|
|
|
|
static bool AddCSSMinSize(nsBoxLayoutState& aState, nsIFrame* aBox,
|
|
|
|
nsSize& aSize, bool& aWidth, bool& aHeightSet);
|
|
|
|
static bool AddCSSMaxSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
|
|
|
|
static bool AddCSSFlex(nsBoxLayoutState& aState, nsIFrame* aBox, nscoord& aFlex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// END OF BOX LAYOUT METHODS
|
|
|
|
// The above methods have been migrated from nsIBox and are in the process of
|
|
|
|
// being refactored. DO NOT USE OUTSIDE OF XUL.
|
|
|
|
|
2012-03-26 09:09:38 -07:00
|
|
|
struct CaretPosition {
|
2013-10-01 14:00:38 -07:00
|
|
|
CaretPosition();
|
|
|
|
~CaretPosition();
|
2012-03-26 09:09:38 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mResultContent;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mContentOffset;
|
2012-03-26 09:09:38 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* gets the first or last possible caret position within the frame
|
|
|
|
*
|
|
|
|
* @param [in] aStart
|
|
|
|
* true for getting the first possible caret position
|
|
|
|
* false for getting the last possible caret position
|
2012-03-26 09:09:38 -07:00
|
|
|
* @return The caret position in a CaretPosition.
|
2007-03-22 10:30:00 -07:00
|
|
|
* the returned value is a 'best effort' in case errors
|
|
|
|
* are encountered rummaging through the frame.
|
|
|
|
*/
|
2012-03-26 09:09:38 -07:00
|
|
|
CaretPosition GetExtremeCaretPosition(bool aStart);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-30 12:17:59 -07:00
|
|
|
/**
|
|
|
|
* Get a line iterator for this frame, if supported.
|
|
|
|
*
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return nullptr if no line iterator is supported.
|
2008-10-30 12:17:59 -07:00
|
|
|
* @note dispose the line iterator using nsILineIterator::DisposeLineIterator
|
|
|
|
*/
|
|
|
|
virtual nsILineIterator* GetLineIterator() = 0;
|
|
|
|
|
2009-07-24 06:32:32 -07:00
|
|
|
/**
|
|
|
|
* If this frame is a next-in-flow, and its prev-in-flow has something on its
|
|
|
|
* overflow list, pull those frames into the child list of this one.
|
|
|
|
*/
|
|
|
|
virtual void PullOverflowsFromPrevInFlow() {}
|
|
|
|
|
2011-01-27 13:53:10 -08:00
|
|
|
/**
|
|
|
|
* Clear the list of child PresShells generated during the last paint
|
|
|
|
* so that we can begin generating a new one.
|
|
|
|
*/
|
|
|
|
void ClearPresShellsFromLastPaint() {
|
|
|
|
PaintedPresShellList()->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag a child PresShell as painted so that it will get its paint count
|
|
|
|
* incremented during empty transactions.
|
|
|
|
*/
|
|
|
|
void AddPaintedPresShell(nsIPresShell* shell) {
|
|
|
|
PaintedPresShellList()->AppendElement(do_GetWeakReference(shell));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increment the paint count of all child PresShells that were painted during
|
|
|
|
* the last repaint.
|
|
|
|
*/
|
|
|
|
void UpdatePaintCountForPaintedPresShells() {
|
|
|
|
nsTArray<nsWeakPtr> * list = PaintedPresShellList();
|
|
|
|
for (int i = 0, l = list->Length(); i < l; i++) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(list->ElementAt(i));
|
|
|
|
|
|
|
|
if (shell) {
|
|
|
|
shell->IncrementPaintCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 16:41:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessors for the absolute containing block.
|
|
|
|
*/
|
|
|
|
bool IsAbsoluteContainer() const { return !!(mState & NS_FRAME_HAS_ABSPOS_CHILDREN); }
|
|
|
|
bool HasAbsolutelyPositionedChildren() const;
|
|
|
|
nsAbsoluteContainingBlock* GetAbsoluteContainingBlock() const;
|
2012-10-26 02:11:24 -07:00
|
|
|
void MarkAsAbsoluteContainingBlock();
|
|
|
|
void MarkAsNotAbsoluteContainingBlock();
|
2011-04-27 16:41:43 -07:00
|
|
|
// Child frame types override this function to select their own child list name
|
|
|
|
virtual mozilla::layout::FrameChildListID GetAbsoluteListID() const { return kAbsoluteList; }
|
|
|
|
|
2011-10-25 20:23:26 -07:00
|
|
|
// Checks if we (or any of our descendents) have NS_FRAME_PAINTED_THEBES set, and
|
|
|
|
// clears this bit if so.
|
|
|
|
bool CheckAndClearPaintedState();
|
|
|
|
|
2011-10-26 16:57:55 -07:00
|
|
|
// CSS visibility just doesn't cut it because it doesn't inherit through
|
|
|
|
// documents. Also if this frame is in a hidden card of a deck then it isn't
|
|
|
|
// visible either and that isn't expressed using CSS visibility. Also if it
|
|
|
|
// is in a hidden view (there are a few cases left and they are hopefully
|
|
|
|
// going away soon).
|
|
|
|
// If the VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY flag is passed then we
|
|
|
|
// ignore the chrome/content boundary, otherwise we stop looking when we
|
|
|
|
// reach it.
|
|
|
|
enum {
|
|
|
|
VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY = 0x01
|
|
|
|
};
|
2012-08-22 08:56:38 -07:00
|
|
|
bool IsVisibleConsideringAncestors(uint32_t aFlags = 0) const;
|
2011-10-26 16:57:55 -07:00
|
|
|
|
2013-02-10 22:22:18 -08:00
|
|
|
struct FrameWithDistance
|
|
|
|
{
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nscoord mXDistance;
|
|
|
|
nscoord mYDistance;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds a frame that is closer to a specified point than a current
|
|
|
|
* distance. Distance is measured as for text selection -- a closer x
|
|
|
|
* distance beats a closer y distance.
|
|
|
|
*
|
|
|
|
* Normally, this function will only check the distance between this
|
2013-12-20 08:38:51 -08:00
|
|
|
* frame's rectangle and the specified point. SVGTextFrame overrides
|
2013-02-10 22:22:18 -08:00
|
|
|
* this so that it can manage all of its descendant frames and take
|
|
|
|
* into account any SVG text layout.
|
|
|
|
*
|
|
|
|
* If aPoint is closer to this frame's rectangle than aCurrentBestFrame
|
|
|
|
* indicates, then aCurrentBestFrame is updated with the distance between
|
|
|
|
* aPoint and this frame's rectangle, and with a pointer to this frame.
|
|
|
|
* If aPoint is not closer, then aCurrentBestFrame is left unchanged.
|
|
|
|
*
|
|
|
|
* @param aPoint The point to check for its distance to this frame.
|
|
|
|
* @param aCurrentBestFrame Pointer to a struct that will be updated with
|
|
|
|
* a pointer to this frame and its distance to aPoint, if this frame
|
|
|
|
* is indeed closer than the current distance in aCurrentBestFrame.
|
|
|
|
*/
|
|
|
|
virtual void FindCloserFrameForSelection(nsPoint aPoint,
|
|
|
|
FrameWithDistance* aCurrentBestFrame);
|
|
|
|
|
2014-01-20 14:02:20 -08:00
|
|
|
/**
|
|
|
|
* Is this a flex item? (i.e. a non-abs-pos child of a flex container)
|
|
|
|
*/
|
|
|
|
inline bool IsFlexItem() const;
|
|
|
|
|
2012-08-02 04:38:51 -07:00
|
|
|
inline bool IsBlockInside() const;
|
|
|
|
inline bool IsBlockOutside() const;
|
|
|
|
inline bool IsInlineOutside() const;
|
2012-08-22 08:56:38 -07:00
|
|
|
inline uint8_t GetDisplay() const;
|
2012-08-02 04:38:49 -07:00
|
|
|
inline bool IsFloating() const;
|
2012-08-02 04:38:50 -07:00
|
|
|
inline bool IsPositioned() const;
|
|
|
|
inline bool IsRelativelyPositioned() const;
|
|
|
|
inline bool IsAbsolutelyPositioned() const;
|
2012-08-02 04:38:49 -07:00
|
|
|
|
2012-08-02 04:38:48 -07:00
|
|
|
/**
|
|
|
|
* Returns the vertical-align value to be used for layout, if it is one
|
|
|
|
* of the enumerated values. If this is an SVG text frame, it returns a value
|
|
|
|
* that corresponds to the value of dominant-baseline. If the
|
|
|
|
* vertical-align property has length or percentage value, this returns
|
|
|
|
* eInvalidVerticalAlign.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t VerticalAlignEnum() const;
|
2012-08-02 04:38:48 -07:00
|
|
|
enum { eInvalidVerticalAlign = 0xFF };
|
|
|
|
|
2012-08-02 04:38:46 -07:00
|
|
|
bool IsSVGText() const { return mState & NS_FRAME_IS_SVG_TEXT; }
|
|
|
|
|
2012-10-10 22:44:59 -07:00
|
|
|
void CreateOwnLayerIfNeeded(nsDisplayListBuilder* aBuilder, nsDisplayList* aList);
|
|
|
|
|
2013-03-04 11:49:39 -08:00
|
|
|
/**
|
|
|
|
* Adds the NS_FRAME_IN_POPUP state bit to aFrame, and
|
|
|
|
* all descendant frames (including cross-doc ones).
|
|
|
|
*/
|
|
|
|
static void AddInPopupStateBitToDescendants(nsIFrame* aFrame);
|
|
|
|
/**
|
|
|
|
* Removes the NS_FRAME_IN_POPUP state bit from aFrame and
|
|
|
|
* all descendant frames (including cross-doc ones), unless
|
|
|
|
* the frame is a popup itself.
|
|
|
|
*/
|
|
|
|
static void RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame);
|
|
|
|
|
2013-09-30 14:26:04 -07:00
|
|
|
/**
|
|
|
|
* Sorts the given nsFrameList, so that for every two adjacent frames in the
|
|
|
|
* list, the former is less than or equal to the latter, according to the
|
|
|
|
* templated IsLessThanOrEqual method.
|
|
|
|
*
|
|
|
|
* Note: this method uses a stable merge-sort algorithm.
|
|
|
|
*/
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
static void SortFrameList(nsFrameList& aFrameList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the given frame list is already sorted, according to the
|
|
|
|
* templated IsLessThanOrEqual function.
|
|
|
|
*/
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
static bool IsFrameListSorted(nsFrameList& aFrameList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if aFrame is in an {ib} split and is NOT one of the
|
|
|
|
* continuations of the first inline in it.
|
|
|
|
*/
|
|
|
|
bool FrameIsNonFirstInIBSplit() const {
|
|
|
|
return (GetStateBits() & NS_FRAME_IS_SPECIAL) &&
|
|
|
|
FirstContinuation()->Properties().Get(nsIFrame::IBSplitSpecialPrevSibling());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if aFrame is in an {ib} split and is NOT one of the
|
|
|
|
* continuations of the last inline in it.
|
|
|
|
*/
|
|
|
|
bool FrameIsNonLastInIBSplit() const {
|
|
|
|
return (GetStateBits() & NS_FRAME_IS_SPECIAL) &&
|
|
|
|
FirstContinuation()->Properties().Get(nsIFrame::IBSplitSpecialSibling());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether this is a frame whose width is used when computing
|
|
|
|
* the font size inflation of its descendants.
|
|
|
|
*/
|
|
|
|
bool IsContainerForFontSizeInflation() const {
|
|
|
|
return GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER;
|
|
|
|
}
|
|
|
|
|
2013-12-02 15:57:50 -08:00
|
|
|
/**
|
|
|
|
* Returns the content node within the anonymous content that this frame
|
|
|
|
* generated and which corresponds to the specified pseudo-element type,
|
|
|
|
* or nullptr if there is no such anonymous content.
|
|
|
|
*/
|
2013-12-02 20:49:03 -08:00
|
|
|
virtual mozilla::dom::Element* GetPseudoElement(nsCSSPseudoElements::Type aType);
|
2013-12-02 15:57:50 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
// Members
|
|
|
|
nsRect mRect;
|
|
|
|
nsIContent* mContent;
|
|
|
|
nsStyleContext* mStyleContext;
|
|
|
|
nsIFrame* mParent;
|
2009-09-18 04:09:36 -07:00
|
|
|
private:
|
2009-10-02 09:27:37 -07:00
|
|
|
nsIFrame* mNextSibling; // doubly-linked list of frames
|
|
|
|
nsIFrame* mPrevSibling; // Do not touch outside SetNextSibling!
|
2011-01-27 13:53:10 -08:00
|
|
|
|
2011-04-29 16:02:33 -07:00
|
|
|
void MarkAbsoluteFramesForDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect);
|
|
|
|
|
2011-01-27 13:53:10 -08:00
|
|
|
static void DestroyPaintedPresShellList(void* propertyValue) {
|
|
|
|
nsTArray<nsWeakPtr>* list = static_cast<nsTArray<nsWeakPtr>*>(propertyValue);
|
|
|
|
list->Clear();
|
|
|
|
delete list;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stores weak references to all the PresShells that were painted during
|
|
|
|
// the last paint event so that we can increment their paint count during
|
|
|
|
// empty transactions
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(PaintedPresShellsProperty, DestroyPaintedPresShellList)
|
|
|
|
|
|
|
|
nsTArray<nsWeakPtr>* PaintedPresShellList() {
|
|
|
|
nsTArray<nsWeakPtr>* list = static_cast<nsTArray<nsWeakPtr>*>(
|
|
|
|
Properties().Get(PaintedPresShellsProperty())
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!list) {
|
|
|
|
list = new nsTArray<nsWeakPtr>();
|
|
|
|
Properties().Set(PaintedPresShellsProperty(), list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2009-09-18 04:09:36 -07:00
|
|
|
protected:
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrameState mState;
|
2009-04-05 17:31:50 -07:00
|
|
|
|
|
|
|
// When there is an overflow area only slightly larger than mRect,
|
|
|
|
// we store a set of four 1-byte deltas from the edges of mRect
|
|
|
|
// rather than allocating a whole separate rectangle property.
|
|
|
|
// Note that these are unsigned values, all measured "outwards"
|
|
|
|
// from the edges of mRect, so /mLeft/ and /mTop/ are reversed from
|
|
|
|
// our normal coordinate system.
|
|
|
|
// If mOverflow.mType == NS_FRAME_OVERFLOW_LARGE, then the
|
|
|
|
// delta values are not meaningful and the overflow area is stored
|
|
|
|
// as a separate rect property.
|
2011-12-05 04:38:46 -08:00
|
|
|
struct VisualDeltas {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mLeft;
|
|
|
|
uint8_t mTop;
|
|
|
|
uint8_t mRight;
|
|
|
|
uint8_t mBottom;
|
2011-12-05 04:38:46 -08:00
|
|
|
bool operator==(const VisualDeltas& aOther) const
|
|
|
|
{
|
|
|
|
return mLeft == aOther.mLeft && mTop == aOther.mTop &&
|
|
|
|
mRight == aOther.mRight && mBottom == aOther.mBottom;
|
|
|
|
}
|
|
|
|
bool operator!=(const VisualDeltas& aOther) const
|
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
};
|
2009-04-05 17:31:50 -07:00
|
|
|
union {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mType;
|
2011-12-05 04:38:46 -08:00
|
|
|
VisualDeltas mVisualDeltas;
|
2009-04-05 17:31:50 -07:00
|
|
|
} mOverflow;
|
2010-10-06 21:25:45 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Helpers
|
|
|
|
/**
|
|
|
|
* Can we stop inside this frame when we're skipping non-rendered whitespace?
|
|
|
|
* @param aForward [in] Are we moving forward (or backward) in content order.
|
|
|
|
* @param aOffset [in/out] At what offset into the frame to start looking.
|
|
|
|
* on output - what offset was reached (whether or not we found a place to stop).
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true: An appropriate offset was found within this frame,
|
2007-03-22 10:30:00 -07:00
|
|
|
* and is given by aOffset.
|
2011-10-17 07:59:28 -07:00
|
|
|
* false: Not found within this frame, need to try the next frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool PeekOffsetNoAmount(bool aForward, int32_t* aOffset) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Search the frame for the next character
|
|
|
|
* @param aForward [in] Are we moving forward (or backward) in content order.
|
|
|
|
* @param aOffset [in/out] At what offset into the frame to start looking.
|
|
|
|
* on output - what offset was reached (whether or not we found a place to stop).
|
2010-12-16 14:17:41 -08:00
|
|
|
* @param aRespectClusters [in] Whether to restrict result to valid cursor locations
|
|
|
|
* (between grapheme clusters) - default TRUE maintains "normal" behavior,
|
|
|
|
* FALSE is used for selection by "code unit" (instead of "character")
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true: An appropriate offset was found within this frame,
|
2007-03-22 10:30:00 -07:00
|
|
|
* and is given by aOffset.
|
2011-10-17 07:59:28 -07:00
|
|
|
* false: Not found within this frame, need to try the next frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRespectClusters = true) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Search the frame for the next word boundary
|
|
|
|
* @param aForward [in] Are we moving forward (or backward) in content order.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aWordSelectEatSpace [in] true: look for non-whitespace following
|
2007-03-22 10:30:00 -07:00
|
|
|
* whitespace (in the direction of movement).
|
2011-10-17 07:59:28 -07:00
|
|
|
* false: look for whitespace following non-whitespace (in the
|
2007-03-22 10:30:00 -07:00
|
|
|
* direction of movement).
|
|
|
|
* @param aIsKeyboardSelect [in] Was the action initiated by a keyboard operation?
|
2011-10-17 07:59:28 -07:00
|
|
|
* If true, punctuation immediately following a word is considered part
|
2007-03-22 10:30:00 -07:00
|
|
|
* of that word. Otherwise, a sequence of punctuation is always considered
|
|
|
|
* as a word on its own.
|
|
|
|
* @param aOffset [in/out] At what offset into the frame to start looking.
|
|
|
|
* on output - what offset was reached (whether or not we found a place to stop).
|
2007-08-29 20:10:19 -07:00
|
|
|
* @param aState [in/out] the state that is carried from frame to frame
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true: An appropriate offset was found within this frame,
|
2007-03-22 10:30:00 -07:00
|
|
|
* and is given by aOffset.
|
2011-10-17 07:59:28 -07:00
|
|
|
* false: Not found within this frame, need to try the next frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-08-29 20:10:19 -07:00
|
|
|
struct PeekWordState {
|
|
|
|
// true when we're still at the start of the search, i.e., we can't return
|
|
|
|
// this point as a valid offset!
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAtStart;
|
2007-08-29 20:10:19 -07:00
|
|
|
// true when we've encountered at least one character of the pre-boundary type
|
|
|
|
// (whitespace if aWordSelectEatSpace is true, non-whitespace otherwise)
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSawBeforeType;
|
2007-08-29 20:10:19 -07:00
|
|
|
// true when the last character encountered was punctuation
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mLastCharWasPunctuation;
|
2008-03-03 00:37:34 -08:00
|
|
|
// true when the last character encountered was whitespace
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mLastCharWasWhitespace;
|
2008-03-03 00:37:34 -08:00
|
|
|
// true when we've seen non-punctuation since the last whitespace
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSeenNonPunctuationSinceWhitespace;
|
2007-11-07 20:33:28 -08:00
|
|
|
// text that's *before* the current frame when aForward is true, *after*
|
2008-03-03 00:37:34 -08:00
|
|
|
// the current frame when aForward is false. Only includes the text
|
|
|
|
// on the current line.
|
2007-11-07 20:33:28 -08:00
|
|
|
nsAutoString mContext;
|
2007-08-29 20:10:19 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
PeekWordState() : mAtStart(true), mSawBeforeType(false),
|
|
|
|
mLastCharWasPunctuation(false), mLastCharWasWhitespace(false),
|
|
|
|
mSeenNonPunctuationSinceWhitespace(false) {}
|
|
|
|
void SetSawBeforeType() { mSawBeforeType = true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
void Update(bool aAfterPunctuation, bool aAfterWhitespace) {
|
2007-08-29 20:10:19 -07:00
|
|
|
mLastCharWasPunctuation = aAfterPunctuation;
|
2008-03-03 00:37:34 -08:00
|
|
|
mLastCharWasWhitespace = aAfterWhitespace;
|
|
|
|
if (aAfterWhitespace) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mSeenNonPunctuationSinceWhitespace = false;
|
2008-03-03 00:37:34 -08:00
|
|
|
} else if (!aAfterPunctuation) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mSeenNonPunctuationSinceWhitespace = true;
|
2008-03-03 00:37:34 -08:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mAtStart = false;
|
2007-08-29 20:10:19 -07:00
|
|
|
}
|
|
|
|
};
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool PeekOffsetWord(bool aForward, bool aWordSelectEatSpace, bool aIsKeyboardSelect,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aOffset, PeekWordState* aState) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Search for the first paragraph boundary before or after the given position
|
|
|
|
* @param aPos See description in nsFrameSelection.h. The following fields are
|
|
|
|
* used by this method:
|
|
|
|
* Input: mDirection
|
|
|
|
* Output: mResultContent, mContentOffset
|
|
|
|
*/
|
2012-07-08 18:09:50 -07:00
|
|
|
nsresult PeekOffsetParagraph(nsPeekOffsetStruct *aPos);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas* GetOverflowAreasProperty();
|
|
|
|
nsRect GetVisualOverflowFromDeltas() const {
|
|
|
|
NS_ABORT_IF_FALSE(mOverflow.mType != NS_FRAME_OVERFLOW_LARGE,
|
|
|
|
"should not be called when overflow is in a property");
|
|
|
|
// Calculate the rect using deltas from the frame's border rect.
|
|
|
|
// Note that the mOverflow.mDeltas fields are unsigned, but we will often
|
|
|
|
// need to return negative values for the left and top, so take care
|
|
|
|
// to cast away the unsigned-ness.
|
2012-08-22 08:56:38 -07:00
|
|
|
return nsRect(-(int32_t)mOverflow.mVisualDeltas.mLeft,
|
|
|
|
-(int32_t)mOverflow.mVisualDeltas.mTop,
|
2010-10-06 21:25:45 -07:00
|
|
|
mRect.width + mOverflow.mVisualDeltas.mRight +
|
|
|
|
mOverflow.mVisualDeltas.mLeft,
|
|
|
|
mRect.height + mOverflow.mVisualDeltas.mBottom +
|
|
|
|
mOverflow.mVisualDeltas.mTop);
|
|
|
|
}
|
2011-12-05 04:38:46 -08:00
|
|
|
/**
|
|
|
|
* Returns true if any overflow changed.
|
|
|
|
*/
|
|
|
|
bool SetOverflowAreas(const nsOverflowAreas& aOverflowAreas);
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPoint GetOffsetToCrossDoc(const nsIFrame* aOther, const int32_t aAPD) const;
|
2009-08-20 14:52:48 -07:00
|
|
|
|
2013-09-30 14:26:04 -07:00
|
|
|
// Helper-functions for SortFrameList():
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
static nsIFrame* SortedMerge(nsIFrame *aLeft, nsIFrame *aRight);
|
|
|
|
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
static nsIFrame* MergeSort(nsIFrame *aSource);
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2009-08-20 14:52:48 -07:00
|
|
|
public:
|
2013-04-30 11:38:52 -07:00
|
|
|
static void IndentBy(FILE* out, int32_t aIndent) {
|
|
|
|
while (--aIndent >= 0) fputs(" ", out);
|
|
|
|
}
|
|
|
|
void ListTag(FILE* out) const {
|
|
|
|
ListTag(out, this);
|
|
|
|
}
|
|
|
|
static void ListTag(FILE* out, const nsIFrame* aFrame) {
|
|
|
|
nsAutoString tmp;
|
|
|
|
aFrame->GetFrameName(tmp);
|
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
|
|
|
fprintf(out, "@%p", static_cast<const void*>(aFrame));
|
|
|
|
}
|
|
|
|
void ListGeneric(FILE* out, int32_t aIndent, uint32_t aFlags) const;
|
2012-09-19 07:36:35 -07:00
|
|
|
enum {
|
|
|
|
TRAVERSE_SUBDOCUMENT_FRAMES = 0x01
|
|
|
|
};
|
2013-04-30 11:38:52 -07:00
|
|
|
virtual void List(FILE* out, int32_t aIndent, uint32_t aFlags = 0) const;
|
|
|
|
/**
|
|
|
|
* lists the frames beginning from the root frame
|
|
|
|
* - calls root frame's List(...)
|
|
|
|
*/
|
|
|
|
static void RootFrameList(nsPresContext* aPresContext,
|
|
|
|
FILE* out, int32_t aIndent);
|
2013-06-18 04:39:58 -07:00
|
|
|
virtual void DumpFrameTree();
|
2014-01-13 14:24:22 -08:00
|
|
|
void DumpFrameTreeLimited();
|
2013-04-30 11:38:52 -07:00
|
|
|
|
2009-08-20 14:52:48 -07:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const = 0;
|
2014-01-05 15:31:14 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
public:
|
2009-08-20 14:52:48 -07:00
|
|
|
NS_IMETHOD_(nsFrameState) GetDebugStateBits() const = 0;
|
|
|
|
NS_IMETHOD DumpRegressionData(nsPresContext* aPresContext,
|
2012-08-22 08:56:38 -07:00
|
|
|
FILE* out, int32_t aIndent) = 0;
|
2009-08-20 14:52:48 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsWeakFrame can be used to keep a reference to a nsIFrame in a safe way.
|
|
|
|
* Whenever an nsIFrame object is deleted, the nsWeakFrames pointing
|
|
|
|
* to it will be cleared.
|
|
|
|
*
|
|
|
|
* Create nsWeakFrame object when it is sure that nsIFrame object
|
|
|
|
* is alive and after some operations which may destroy the nsIFrame
|
|
|
|
* (for example any DOM modifications) use IsAlive() or GetFrame() methods to
|
|
|
|
* check whether it is safe to continue to use the nsIFrame object.
|
|
|
|
*
|
|
|
|
* @note The usage of this class should be kept to a minimum.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsWeakFrame {
|
|
|
|
public:
|
2012-07-30 07:20:58 -07:00
|
|
|
nsWeakFrame() : mPrev(nullptr), mFrame(nullptr) { }
|
2007-11-17 07:47:38 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsWeakFrame(const nsWeakFrame& aOther) : mPrev(nullptr), mFrame(nullptr)
|
2010-08-30 11:37:55 -07:00
|
|
|
{
|
|
|
|
Init(aOther.GetFrame());
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsWeakFrame(nsIFrame* aFrame) : mPrev(nullptr), mFrame(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
Init(aFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsWeakFrame& operator=(nsWeakFrame& aOther) {
|
|
|
|
Init(aOther.GetFrame());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsWeakFrame& operator=(nsIFrame* aFrame) {
|
|
|
|
Init(aFrame);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* operator->()
|
|
|
|
{
|
|
|
|
return mFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator nsIFrame*()
|
|
|
|
{
|
|
|
|
return mFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear(nsIPresShell* aShell) {
|
|
|
|
if (aShell) {
|
|
|
|
aShell->RemoveWeakFrame(this);
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrame = nullptr;
|
|
|
|
mPrev = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAlive() { return !!mFrame; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-30 11:37:55 -07:00
|
|
|
nsIFrame* GetFrame() const { return mFrame; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsWeakFrame* GetPreviousWeakFrame() { return mPrev; }
|
|
|
|
|
|
|
|
void SetPreviousWeakFrame(nsWeakFrame* aPrev) { mPrev = aPrev; }
|
|
|
|
|
|
|
|
~nsWeakFrame()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
Clear(mFrame ? mFrame->PresContext()->GetPresShell() : nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
private:
|
2013-09-25 06:48:20 -07:00
|
|
|
void Init(nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsWeakFrame* mPrev;
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2013-02-27 15:05:44 -08:00
|
|
|
inline bool
|
|
|
|
nsFrameList::ContinueRemoveFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!aFrame->GetPrevSibling() || !aFrame->GetNextSibling(),
|
|
|
|
"Forgot to call StartRemoveFrame?");
|
|
|
|
if (aFrame == mLastChild) {
|
|
|
|
MOZ_ASSERT(!aFrame->GetNextSibling(), "broken frame list");
|
|
|
|
nsIFrame* prevSibling = aFrame->GetPrevSibling();
|
|
|
|
if (!prevSibling) {
|
|
|
|
MOZ_ASSERT(aFrame == mFirstChild, "broken frame list");
|
|
|
|
mFirstChild = mLastChild = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(prevSibling->GetNextSibling() == aFrame, "Broken frame linkage");
|
|
|
|
prevSibling->SetNextSibling(nullptr);
|
|
|
|
mLastChild = prevSibling;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (aFrame == mFirstChild) {
|
|
|
|
MOZ_ASSERT(!aFrame->GetPrevSibling(), "broken frame list");
|
|
|
|
mFirstChild = aFrame->GetNextSibling();
|
|
|
|
aFrame->SetNextSibling(nullptr);
|
|
|
|
MOZ_ASSERT(mFirstChild, "broken frame list");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
nsFrameList::StartRemoveFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (aFrame->GetPrevSibling() && aFrame->GetNextSibling()) {
|
|
|
|
UnhookFrameFromSiblings(aFrame);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return ContinueRemoveFrame(aFrame);
|
|
|
|
}
|
|
|
|
|
2009-07-28 05:51:08 -07:00
|
|
|
inline void
|
2009-09-18 04:09:36 -07:00
|
|
|
nsFrameList::Enumerator::Next()
|
|
|
|
{
|
2009-07-28 05:51:08 -07:00
|
|
|
NS_ASSERTION(!AtEnd(), "Should have checked AtEnd()!");
|
|
|
|
mFrame = mFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2009-09-29 12:47:05 -07:00
|
|
|
inline
|
|
|
|
nsFrameList::FrameLinkEnumerator::
|
|
|
|
FrameLinkEnumerator(const nsFrameList& aList, nsIFrame* aPrevFrame)
|
|
|
|
: Enumerator(aList)
|
|
|
|
{
|
|
|
|
mPrev = aPrevFrame;
|
|
|
|
mFrame = aPrevFrame ? aPrevFrame->GetNextSibling() : aList.FirstChild();
|
|
|
|
}
|
2012-08-02 04:38:49 -07:00
|
|
|
|
2013-09-30 14:26:04 -07:00
|
|
|
inline void
|
|
|
|
nsFrameList::FrameLinkEnumerator::Next()
|
|
|
|
{
|
|
|
|
mPrev = mFrame;
|
|
|
|
Enumerator::Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper-functions for nsIFrame::SortFrameList()
|
|
|
|
// ---------------------------------------------------
|
|
|
|
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
/* static */ nsIFrame*
|
|
|
|
nsIFrame::SortedMerge(nsIFrame *aLeft, nsIFrame *aRight)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aLeft && aRight, "SortedMerge must have non-empty lists");
|
|
|
|
|
|
|
|
nsIFrame *result;
|
|
|
|
// Unroll first iteration to avoid null-check 'result' inside the loop.
|
|
|
|
if (IsLessThanOrEqual(aLeft, aRight)) {
|
|
|
|
result = aLeft;
|
|
|
|
aLeft = aLeft->GetNextSibling();
|
|
|
|
if (!aLeft) {
|
|
|
|
result->SetNextSibling(aRight);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = aRight;
|
|
|
|
aRight = aRight->GetNextSibling();
|
|
|
|
if (!aRight) {
|
|
|
|
result->SetNextSibling(aLeft);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame *last = result;
|
|
|
|
for (;;) {
|
|
|
|
if (IsLessThanOrEqual(aLeft, aRight)) {
|
|
|
|
last->SetNextSibling(aLeft);
|
|
|
|
last = aLeft;
|
|
|
|
aLeft = aLeft->GetNextSibling();
|
|
|
|
if (!aLeft) {
|
|
|
|
last->SetNextSibling(aRight);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
last->SetNextSibling(aRight);
|
|
|
|
last = aRight;
|
|
|
|
aRight = aRight->GetNextSibling();
|
|
|
|
if (!aRight) {
|
|
|
|
last->SetNextSibling(aLeft);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
/* static */ nsIFrame*
|
|
|
|
nsIFrame::MergeSort(nsIFrame *aSource)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aSource, "MergeSort null arg");
|
|
|
|
|
|
|
|
nsIFrame *sorted[32] = { nullptr };
|
|
|
|
nsIFrame **fill = &sorted[0];
|
|
|
|
nsIFrame **left;
|
|
|
|
nsIFrame *rest = aSource;
|
|
|
|
|
|
|
|
do {
|
|
|
|
nsIFrame *current = rest;
|
|
|
|
rest = rest->GetNextSibling();
|
|
|
|
current->SetNextSibling(nullptr);
|
|
|
|
|
|
|
|
// Merge it with sorted[0] if present; then merge the result with sorted[1] etc.
|
|
|
|
// sorted[0] is a list of length 1 (or nullptr).
|
|
|
|
// sorted[1] is a list of length 2 (or nullptr).
|
|
|
|
// sorted[2] is a list of length 4 (or nullptr). etc.
|
|
|
|
for (left = &sorted[0]; left != fill && *left; ++left) {
|
|
|
|
current = SortedMerge<IsLessThanOrEqual>(*left, current);
|
|
|
|
*left = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fill the empty slot that we couldn't merge with the last result.
|
|
|
|
*left = current;
|
|
|
|
|
|
|
|
if (left == fill)
|
|
|
|
++fill;
|
|
|
|
} while (rest);
|
|
|
|
|
|
|
|
// Collect and merge the results.
|
|
|
|
nsIFrame *result = nullptr;
|
|
|
|
for (left = &sorted[0]; left != fill; ++left) {
|
|
|
|
if (*left) {
|
|
|
|
result = result ? SortedMerge<IsLessThanOrEqual>(*left, result) : *left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
/* static */ void
|
|
|
|
nsIFrame::SortFrameList(nsFrameList& aFrameList)
|
|
|
|
{
|
|
|
|
nsIFrame* head = MergeSort<IsLessThanOrEqual>(aFrameList.FirstChild());
|
|
|
|
aFrameList = nsFrameList(head, nsLayoutUtils::GetLastSibling(head));
|
|
|
|
MOZ_ASSERT(IsFrameListSorted<IsLessThanOrEqual>(aFrameList),
|
|
|
|
"After we sort a frame list, it should be in sorted order...");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
|
|
|
|
/* static */ bool
|
|
|
|
nsIFrame::IsFrameListSorted(nsFrameList& aFrameList)
|
|
|
|
{
|
|
|
|
if (aFrameList.IsEmpty()) {
|
|
|
|
// empty lists are trivially sorted.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We'll walk through the list with two iterators, one trailing behind the
|
|
|
|
// other. The list is sorted IFF trailingIter <= iter, across the whole list.
|
|
|
|
nsFrameList::Enumerator trailingIter(aFrameList);
|
|
|
|
nsFrameList::Enumerator iter(aFrameList);
|
|
|
|
iter.Next(); // Skip |iter| past first frame. (List is nonempty, so we can.)
|
|
|
|
|
|
|
|
// Now, advance the iterators in parallel, comparing each adjacent pair.
|
|
|
|
while (!iter.AtEnd()) {
|
|
|
|
MOZ_ASSERT(!trailingIter.AtEnd(), "trailing iter shouldn't finish first");
|
|
|
|
if (!IsLessThanOrEqual(trailingIter.get(), iter.get())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
trailingIter.Next();
|
|
|
|
iter.Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We made it to the end without returning early, so the list is sorted.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsIFrame_h___ */
|