WBRFrame.cpp (2537B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* rendering object for HTML <wbr> elements */ 8 9 #include "mozilla/PresShell.h" 10 #include "nsHTMLParts.h" 11 #include "nsIFrame.h" 12 13 using namespace mozilla; 14 15 namespace mozilla { 16 17 class WBRFrame final : public nsIFrame { 18 public: 19 NS_DECL_FRAMEARENA_HELPERS(WBRFrame) 20 21 friend nsIFrame* ::NS_NewWBRFrame(mozilla::PresShell* aPresShell, 22 ComputedStyle* aStyle); 23 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; 33 34 protected: 35 explicit WBRFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) 36 : nsIFrame(aStyle, aPresContext, kClassID) {} 37 }; 38 39 } // namespace mozilla 40 41 nsIFrame* NS_NewWBRFrame(mozilla::PresShell* aPresShell, 42 ComputedStyle* aStyle) { 43 return new (aPresShell) WBRFrame(aStyle, aPresShell->GetPresContext()); 44 } 45 46 NS_IMPL_FRAMEARENA_HELPERS(WBRFrame) 47 48 nsIFrame::FrameSearchResult WBRFrame::PeekOffsetNoAmount(bool aForward, 49 int32_t* aOffset) { 50 NS_ASSERTION(aOffset && *aOffset <= 1, "aOffset out of range"); 51 // WBR frames can not contain text or non-rendered whitespace 52 return CONTINUE; 53 } 54 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 59 return CONTINUE; 60 } 61 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 67 return CONTINUE; 68 }