1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* rendering object for HTML <wbr> elements */
9 #include "mozilla/PresShell.h"
10 #include "nsHTMLParts.h"
13 using namespace mozilla
;
17 class WBRFrame final
: public nsIFrame
{
19 NS_DECL_FRAMEARENA_HELPERS(WBRFrame
)
21 friend nsIFrame
* ::NS_NewWBRFrame(mozilla::PresShell
* aPresShell
,
22 ComputedStyle
* aStyle
);
24 virtual FrameSearchResult
PeekOffsetNoAmount(bool aForward
,
25 int32_t* aOffset
) override
;
26 virtual FrameSearchResult
PeekOffsetCharacter(
27 bool aForward
, int32_t* aOffset
,
28 PeekOffsetCharacterOptions aOptions
=
29 PeekOffsetCharacterOptions()) override
;
30 virtual FrameSearchResult
PeekOffsetWord(
31 bool aForward
, bool aWordSelectEatSpace
, bool aIsKeyboardSelect
,
32 int32_t* aOffset
, PeekWordState
* aState
, bool aTrimSpaces
) override
;
35 explicit WBRFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
36 : nsIFrame(aStyle
, aPresContext
, kClassID
) {}
39 } // namespace mozilla
41 nsIFrame
* NS_NewWBRFrame(mozilla::PresShell
* aPresShell
,
42 ComputedStyle
* aStyle
) {
43 return new (aPresShell
) WBRFrame(aStyle
, aPresShell
->GetPresContext());
46 NS_IMPL_FRAMEARENA_HELPERS(WBRFrame
)
48 nsIFrame::FrameSearchResult
WBRFrame::PeekOffsetNoAmount(bool aForward
,
50 NS_ASSERTION(aOffset
&& *aOffset
<= 1, "aOffset out of range");
51 // WBR frames can not contain text or non-rendered whitespace
55 nsIFrame::FrameSearchResult
WBRFrame::PeekOffsetCharacter(
56 bool aForward
, int32_t* aOffset
, PeekOffsetCharacterOptions aOptions
) {
57 NS_ASSERTION(aOffset
&& *aOffset
<= 1, "aOffset out of range");
58 // WBR frames can not contain characters
62 nsIFrame::FrameSearchResult
WBRFrame::PeekOffsetWord(
63 bool aForward
, bool aWordSelectEatSpace
, bool aIsKeyboardSelect
,
64 int32_t* aOffset
, PeekWordState
* aState
, bool aTrimSpaces
) {
65 NS_ASSERTION(aOffset
&& *aOffset
<= 1, "aOffset out of range");
66 // WBR frames can never contain text so we'll never find a word inside them