Changeset 157373 in webkit


Ignore:
Timestamp:
Oct 13, 2013, 9:00:10 AM (11 years ago)
Author:
Antti Koivisto
Message:

Text::renderer() should return RenderText
https://bugs.webkit.org/show_bug.cgi?id=122729

Reviewed by Andreas Kling.

Tighten typing.

Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r157372 r157373  
     12013-10-13  Antti Koivisto  <antti@apple.com>
     2
     3        Text::renderer() should return RenderText
     4        https://bugs.webkit.org/show_bug.cgi?id=122729
     5
     6        Reviewed by Andreas Kling.
     7       
     8        Tighten typing.
     9
    1102013-10-13  Andreas Kling  <akling@apple.com>
    211
  • trunk/Source/WebCore/dom/Text.cpp

    r155908 r157373  
    8888
    8989    if (renderer())
    90         toRenderText(renderer())->setTextWithOffset(dataImpl(), 0, oldStr.length());
     90        renderer()->setTextWithOffset(dataImpl(), 0, oldStr.length());
    9191
    9292    return newText.release();
  • trunk/Source/WebCore/dom/Text.h

    r157044 r157373  
    5252    virtual bool canContainRangeEndPoint() const OVERRIDE FINAL { return true; }
    5353
     54    RenderText* renderer() const;
     55
    5456protected:
    5557    Text(Document& document, const String& data, ConstructionType type)
     
    7173};
    7274
    73 inline bool isText(const Node& node)
    74 {
    75     return node.isTextNode();
    76 }
     75void isText(const Text&); // Catch unnecessary runtime check of type known at compile time.
     76void isText(const ContainerNode&); // Catch unnecessary runtime check of type known at compile time.
     77inline bool isText(const Node& node) { return node.isTextNode(); }
    7778
    7879NODE_TYPE_CASTS(Text)
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r157018 r157373  
    735735    document().updateLayout();
    736736
    737     RenderText* textRenderer = toRenderText(textNode->renderer());
     737    RenderText* textRenderer = textNode->renderer();
    738738    if (!textRenderer)
    739739        return;
  • trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp

    r157292 r157373  
    4040#include "NodeTraversal.h"
    4141#include "RenderTableCell.h"
     42#include "RenderText.h"
    4243#include "Text.h"
    4344#include "VisibleUnits.h"
  • trunk/Source/WebCore/editing/HTMLInterchange.cpp

    r156527 r157373  
    2828
    2929#include "RenderElement.h"
     30#include "RenderText.h"
    3031#include "Text.h"
    3132#include "TextIterator.h"
  • trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp

    r154938 r157373  
    5858
    5959    if (passwordEchoEnabled) {
    60         RenderText* renderText = toRenderText(m_node->renderer());
     60        RenderText* renderText = m_node->renderer();
    6161        if (renderText && renderText->isSecure())
    6262            renderText->momentarilyRevealLastTypedCharacter(m_offset + m_text.length() - 1);
  • trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp

    r156527 r157373  
    3636#include "Range.h"
    3737#include "RenderElement.h"
     38#include "RenderText.h"
    3839#include "Text.h"
    3940#include "VisiblePosition.h"
  • trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp

    r156289 r157373  
    3535#include "InsertLineBreakCommand.h"
    3636#include "NodeTraversal.h"
    37 #include "RenderObject.h"
     37#include "RenderText.h"
    3838#include "Text.h"
    3939#include "VisibleUnits.h"
  • trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp

    r157368 r157373  
    668668}
    669669
    670 static inline bool nodeHasVisibleRenderText(Text* text)
    671 {
    672     return text->renderer() && toRenderText(text->renderer())->hasRenderedText();
     670static inline bool hasRenderedText(const Text& text)
     671{
     672    return text.renderer() && text.renderer()->hasRenderedText();
    673673}
    674674
     
    678678
    679679    Node* lastLeafInserted = insertedNodes.lastLeafInserted();
    680     if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRenderText(toText(lastLeafInserted))
     680    if (lastLeafInserted && lastLeafInserted->isTextNode() && !hasRenderedText(toText(*lastLeafInserted))
    681681        && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag)
    682682        && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) {
     
    688688    // because it is a top level node in the fragment and the user can't insert into those elements.
    689689    Node* firstNodeInserted = insertedNodes.firstNodeInserted();
    690     if (firstNodeInserted && firstNodeInserted->isTextNode() && !nodeHasVisibleRenderText(toText(firstNodeInserted))) {
     690    if (firstNodeInserted && firstNodeInserted->isTextNode() && !hasRenderedText(toText(*firstNodeInserted))) {
    691691        insertedNodes.willRemoveNode(firstNodeInserted);
    692692        removeNode(firstNodeInserted);
  • trunk/Source/WebCore/page/Frame.cpp

    r157056 r157373  
    7878#include "RegularExpression.h"
    7979#include "RenderTableCell.h"
     80#include "RenderText.h"
    8081#include "RenderTextControl.h"
    8182#include "RenderTheme.h"
  • trunk/Source/WebCore/rendering/RenderText.h

    r157366 r157373  
    2626#include "RenderElement.h"
    2727#include "RenderTextLineBoxes.h"
     28#include "Text.h"
    2829#include <wtf/Forward.h>
    2930
     
    3132
    3233class InlineTextBox;
    33 class Text;
    3434
    3535class RenderText : public RenderObject {
     
    134134
    135135    InlineTextBox* findNextInlineTextBox(int offset, int& pos) const { return m_lineBoxes.findNext(offset, pos); }
    136 
    137     void checkConsistency() const;
    138136
    139137    bool isAllCollapsibleWhitespace() const;
     
    251249}
    252250
    253 #ifdef NDEBUG
    254 inline void RenderText::checkConsistency() const
    255 {
    256 }
    257 #endif
    258 
    259251void applyTextTransform(const RenderStyle*, String&, UChar);
    260252
     253inline RenderText* Text::renderer() const
     254{
     255    return toRenderText(Node::renderer());
     256}
     257
    261258} // namespace WebCore
    262259
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r157265 r157373  
    410410    if (!textNode.attached())
    411411        return;
    412     RenderText* textRenderer = toRenderText(textNode.renderer());
     412    RenderText* textRenderer = textNode.renderer();
    413413    if (!textRenderer) {
    414414        attachTextRenderer(textNode);
     
    629629static void updateTextStyle(Text& text)
    630630{
    631     RenderText* renderer = toRenderText(text.renderer());
     631    RenderText* renderer = text.renderer();
    632632
    633633    if (!text.needsStyleRecalc())
Note: See TracChangeset for help on using the changeset viewer.