RenderRuby.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifndef RenderRuby_h
  31. #define RenderRuby_h
  32. #include "RenderBlock.h"
  33. #include "RenderInline.h"
  34. namespace WebCore {
  35. // Following the HTML 5 spec, the box object model for a <ruby> element allows several runs of ruby
  36. // bases with their respective ruby texts looks as follows:
  37. //
  38. // 1 RenderRuby object, corresponding to the whole <ruby> HTML element
  39. // 1+ RenderRubyRun (anonymous)
  40. // 0 or 1 RenderRubyText - shuffled to the front in order to re-use existing block layouting
  41. // 0-n inline object(s)
  42. // 0 or 1 RenderRubyBase - contains the inline objects that make up the ruby base
  43. // 1-n inline object(s)
  44. //
  45. // Note: <rp> elements are defined as having 'display:none' and thus normally are not assigned a renderer.
  46. //
  47. // Generated :before/:after content is shunted into anonymous inline blocks
  48. // <ruby> when used as 'display:inline'
  49. class RenderRubyAsInline : public RenderInline {
  50. public:
  51. RenderRubyAsInline(Element*);
  52. virtual ~RenderRubyAsInline();
  53. virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
  54. virtual void removeChild(RenderObject* child);
  55. protected:
  56. virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
  57. private:
  58. virtual bool isRuby() const { return true; }
  59. virtual const char* renderName() const { return "RenderRuby (inline)"; }
  60. virtual bool createsAnonymousWrapper() const { return true; }
  61. virtual void removeLeftoverAnonymousBlock(RenderBlock*) { ASSERT_NOT_REACHED(); }
  62. };
  63. // <ruby> when used as 'display:block' or 'display:inline-block'
  64. class RenderRubyAsBlock : public RenderBlock {
  65. public:
  66. RenderRubyAsBlock(Element*);
  67. virtual ~RenderRubyAsBlock();
  68. virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
  69. virtual void removeChild(RenderObject* child);
  70. protected:
  71. virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
  72. private:
  73. virtual bool isRuby() const { return true; }
  74. virtual const char* renderName() const { return "RenderRuby (block)"; }
  75. virtual bool createsAnonymousWrapper() const { return true; }
  76. virtual void removeLeftoverAnonymousBlock(RenderBlock*) { ASSERT_NOT_REACHED(); }
  77. };
  78. } // namespace WebCore
  79. #endif // RenderRuby_h