1 /* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_RUBY_RUN_H_ 32 #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_RUBY_RUN_H_ 33 34 #include "third_party/blink/renderer/core/layout/layout_block_flow.h" 35 #include "third_party/blink/renderer/platform/text/text_break_iterator.h" 36 37 namespace blink { 38 39 class LayoutRubyBase; 40 class LayoutRubyText; 41 template <typename Base> 42 class LayoutNGMixin; 43 44 // LayoutRubyRun are 'inline-block/table' like objects,and wrap a single pairing 45 // of a ruby base with its ruby text(s). 46 // See LayoutRuby.h for further comments on the structure 47 48 class LayoutRubyRun : public LayoutBlockFlow { 49 public: 50 ~LayoutRubyRun() override; 51 52 bool HasRubyText() const; 53 bool HasRubyBase() const; 54 LayoutRubyText* RubyText() const; 55 LayoutRubyBase* RubyBase() const; 56 LayoutRubyBase* 57 RubyBaseSafe(); // creates the base if it doesn't already exist 58 59 LayoutObject* LayoutSpecialExcludedChild(bool relayout_children, 60 SubtreeLayoutScope&) override; 61 void UpdateLayout() override; 62 63 bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const override; 64 void AddChild(LayoutObject* child, 65 LayoutObject* before_child = nullptr) override; 66 void RemoveChild(LayoutObject* child) override; 67 68 void GetOverhang(bool first_line, 69 LayoutObject* start_layout_object, 70 LayoutObject* end_layout_object, 71 int& start_overhang, 72 int& end_overhang) const; 73 74 static LayoutRubyRun* StaticCreateRubyRun( 75 const LayoutObject* parent_ruby, 76 const LayoutBlock& containing_block); 77 78 bool CanBreakBefore(const LazyLineBreakIterator&) const; 79 GetName()80 const char* GetName() const override { 81 NOT_DESTROYED(); 82 return "LayoutRubyRun"; 83 } 84 85 protected: 86 LayoutRubyBase* CreateRubyBase() const; 87 88 private: 89 // The argument must be nullptr. 90 explicit LayoutRubyRun(Element*); 91 IsOfType(LayoutObjectType type)92 bool IsOfType(LayoutObjectType type) const override { 93 NOT_DESTROYED(); 94 return type == kLayoutObjectRubyRun || LayoutBlockFlow::IsOfType(type); 95 } CreatesAnonymousWrapper()96 bool CreatesAnonymousWrapper() const override { 97 NOT_DESTROYED(); 98 return true; 99 } RemoveLeftoverAnonymousBlock(LayoutBlock *)100 void RemoveLeftoverAnonymousBlock(LayoutBlock*) override { NOT_DESTROYED(); } 101 102 friend class LayoutNGMixin<LayoutRubyRun>; 103 }; 104 105 template <> 106 struct DowncastTraits<LayoutRubyRun> { 107 static bool AllowFrom(const LayoutObject& object) { 108 return object.IsRubyRun(); 109 } 110 }; 111 112 } // namespace blink 113 114 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_RUBY_RUN_H_ 115