WebCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Jan 2009 20:23:04 +0000 (20:23 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Jan 2009 20:23:04 +0000 (20:23 +0000)
2009-01-25  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        Bug 23522: use checked casts for render tree
        https://bugs.webkit.org/show_bug.cgi?id=23522

        Step one: RenderText.

        Also change set of RenderFlow* to be a ListHashSet as the comment in the
        header indicated.

        * dom/CharacterData.cpp:
        (WebCore::CharacterData::setData): Use toRenderText.
        (WebCore::CharacterData::appendData): Ditto.
        (WebCore::CharacterData::insertData): Ditto.
        (WebCore::CharacterData::deleteData): Ditto.
        (WebCore::CharacterData::replaceData): Ditto.
        * dom/ContainerNode.cpp:
        (WebCore::ContainerNode::getUpperLeftCorner): Ditto.
        (WebCore::ContainerNode::getLowerRightCorner): Ditto.
        * dom/Position.cpp:
        (WebCore::nextRenderedEditable): Ditto.
        (WebCore::previousRenderedEditable): Ditto.
        (WebCore::Position::renderedOffset): Ditto. Also use function members
        instead of data members of InlineTextBox.
        (WebCore::Position::upstream): Ditto.
        (WebCore::Position::downstream): Ditto.
        (WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight): Ditto.
        (WebCore::Position::inRenderedText): Ditto.
        (WebCore::Position::isRenderedCharacter): Ditto.
        (WebCore::searchAheadForBetterMatch): Ditto.
        (WebCore::Position::getInlineBoxAndOffset): Ditto.

        * dom/Range.cpp: Added include of VisiblePosition.h now that it's no longer
        included in RenderObject.h.

        * dom/Text.cpp:
        (WebCore::Text::splitText): Use toRenderText.
        (WebCore::Text::recalcStyle): Ditto.
        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::deleteInsignificantText): Ditto.
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::debugRenderer): Ditto.
        * editing/TextIterator.cpp:
        (WebCore::TextIterator::handleTextNode): Ditto.
        (WebCore::TextIterator::handleTextBox): Ditto.
        (WebCore::TextIterator::emitText): Ditto.
        (WebCore::SimplifiedBackwardsTextIterator::handleTextNode): Ditto.

        * editing/VisiblePosition.cpp: Added include of FloatQuad.h now that it's
        no longer included in RenderObject.h.
        * inspector/InspectorController.cpp: Ditto.
        * page/Frame.cpp: Ditto.
        * rendering/RenderBox.cpp: Ditto.
        * rendering/RenderInline.cpp: Ditto.
        * rendering/RenderPath.cpp: Ditto.
        * rendering/RenderSVGContainer.cpp: Ditto.
        * rendering/RenderSVGImage.cpp: Ditto.
        * rendering/RenderSVGInlineText.cpp: Ditto.
        * rendering/RenderSVGTSpan.cpp: Ditto.
        * rendering/RenderSVGText.cpp: Ditto.
        * rendering/RenderSVGTextPath.cpp: Ditto.
        * rendering/RenderTableCell.cpp: Ditto.
        * rendering/RenderView.cpp: Ditto.

        * editing/visible_units.cpp:
        (WebCore::startPositionForLine): Use function members instead of data
        members of InlineTextBox.
        (WebCore::endPositionForLine): Ditto.
        (WebCore::startOfParagraph): Use toRenderText.
        (WebCore::endOfParagraph): Ditto.

        * page/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored): Use toRenderText.
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::placeBoxesHorizontally): Ditto.
        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::deleteLine): Ditto.
        (WebCore::InlineTextBox::extractLine): Ditto.
        (WebCore::InlineTextBox::attachLine): Ditto.
        (WebCore::InlineTextBox::placeEllipsisBox): Ditto.
        (WebCore::InlineTextBox::paintDecoration): Ditto.
        (WebCore::InlineTextBox::paintCompositionUnderline): Ditto.
        (WebCore::InlineTextBox::offsetForPosition): Ditto.
        (WebCore::InlineTextBox::positionForOffset): Ditto.

        * rendering/InlineTextBox.h: Made most members private. Use toRenderText.

        * rendering/RenderArena.cpp:
        (WebCore::RenderArena::allocate): Use static_cast instead of C-style cast.
        (WebCore::RenderArena::free): Ditto.

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::addContinuationWithOutline): Use ListHashSet<RenderFlow*>
        instead of RenderFlowSequencedSet.
        (WebCore::RenderBlock::paintContinuationOutlines): Ditto.
        (WebCore::stripTrailingSpace): Ditto.
        (WebCore::RenderBlock::calcInlinePrefWidths): Ditto.
        (WebCore::RenderBlock::updateFirstLetter): Ditto.

        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::addChild): Use toRenderText.

        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::dirtyLinesFromChangedChild): Use ListHashSet<RenderFlow*>
        instead of RenderFlowSequencedSet.
        (WebCore::RenderFlow::paintLines): Ditto.

        * rendering/RenderMenuList.cpp: Removed some unneeded includes.

        * rendering/RenderMenuList.h: Added now-needed forward declaration of RenderText.
        Made more members private.

        * rendering/RenderObject.cpp: Updated includes.
        (WebCore::RenderObject::isEditable): Use toRenderText.
        (WebCore::RenderObject::positionForPoint): Made non-inline so we wouldn't have to
        include VisiblePosition.h in the header just for this.

        * rendering/RenderObject.h: Removed unneeded includes and forward declarations.
        Changed special vertical position values to be constants rather than an enum.
        Eliminated RenderFlowSequencedSet, and changed clients to use ListHashSet<RenderFlow*>.

        * rendering/RenderText.cpp:
        (WebCore::RenderText::findNextInlineTextBox): Use function members instead of
        data members of InlineTextBox.
        (WebCore::RenderText::positionForCoordinates): Ditto.
        (WebCore::isInlineFlowOrEmptyText): Use toRenderText.
        (WebCore::RenderText::previousCharacter): Use function members instead of
        data members of InlineTextBox.
        (WebCore::RenderText::position): Ditto.
        (WebCore::RenderText::caretMinOffset): Ditto.
        (WebCore::RenderText::caretMaxOffset): Ditto.
        (WebCore::RenderText::caretMaxRenderedOffset): Ditto.

        * rendering/RenderText.h: Added definition of toRenderText.

        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::textWithHardLineBreaks): Use toRenderText.
        * rendering/RenderTreeAsText.cpp:
        (WebCore::operator<<): Use toRenderText and toRenderBox.
        (WebCore::writeTextRun): Ditto.
        (WebCore::write): Ditto.

        * rendering/bidi.cpp:
        (WebCore::InlineIterator::increment): Use toRenderText.
        (WebCore::InlineIterator::current): Ditto.
        (WebCore::checkMidpoints): Ditto.
        (WebCore::RenderBlock::computeHorizontalPositionsForLine): Ditto.
        (WebCore::RenderBlock::layoutInlineChildren): Ditto.
        (WebCore::RenderBlock::determineStartPosition): Ditto.
        (WebCore::shouldSkipWhitespaceAfterStartObject): Ditto.
        (WebCore::RenderBlock::findNextLineBreak): Ditto.

WebKit/mac:

2009-01-25  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        Bug 23522: use checked casts for render tree
        https://bugs.webkit.org/show_bug.cgi?id=23522

        Step one: RenderText.

        * WebView/WebRenderNode.mm:
        (copyRenderNode): Use toRenderText.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40229 268f45cc-cd09-0410-ab3c-d52691b4dbfc

43 files changed:
WebCore/ChangeLog
WebCore/dom/CharacterData.cpp
WebCore/dom/ContainerNode.cpp
WebCore/dom/Position.cpp
WebCore/dom/Range.cpp
WebCore/dom/Text.cpp
WebCore/editing/CompositeEditCommand.cpp
WebCore/editing/SelectionController.cpp
WebCore/editing/TextIterator.cpp
WebCore/editing/VisiblePosition.cpp
WebCore/editing/visible_units.cpp
WebCore/inspector/InspectorController.cpp
WebCore/page/AccessibilityRenderObject.cpp
WebCore/page/Frame.cpp
WebCore/rendering/InlineFlowBox.cpp
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/InlineTextBox.h
WebCore/rendering/RenderArena.cpp
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderContainer.cpp
WebCore/rendering/RenderFlow.cpp
WebCore/rendering/RenderInline.cpp
WebCore/rendering/RenderMenuList.cpp
WebCore/rendering/RenderMenuList.h
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderPath.cpp
WebCore/rendering/RenderSVGContainer.cpp
WebCore/rendering/RenderSVGImage.cpp
WebCore/rendering/RenderSVGInlineText.cpp
WebCore/rendering/RenderSVGTSpan.cpp
WebCore/rendering/RenderSVGText.cpp
WebCore/rendering/RenderSVGTextPath.cpp
WebCore/rendering/RenderTableCell.cpp
WebCore/rendering/RenderText.cpp
WebCore/rendering/RenderText.h
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTreeAsText.cpp
WebCore/rendering/RenderView.cpp
WebCore/rendering/bidi.cpp
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebRenderNode.mm

index 6d160d2..728bdeb 100644 (file)
@@ -1,3 +1,157 @@
+2009-01-25  Darin Adler  <darin@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Bug 23522: use checked casts for render tree
+        https://bugs.webkit.org/show_bug.cgi?id=23522
+
+        Step one: RenderText.
+
+        Also change set of RenderFlow* to be a ListHashSet as the comment in the
+        header indicated.
+
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::setData): Use toRenderText.
+        (WebCore::CharacterData::appendData): Ditto.
+        (WebCore::CharacterData::insertData): Ditto.
+        (WebCore::CharacterData::deleteData): Ditto.
+        (WebCore::CharacterData::replaceData): Ditto.
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::getUpperLeftCorner): Ditto.
+        (WebCore::ContainerNode::getLowerRightCorner): Ditto.
+        * dom/Position.cpp:
+        (WebCore::nextRenderedEditable): Ditto.
+        (WebCore::previousRenderedEditable): Ditto.
+        (WebCore::Position::renderedOffset): Ditto. Also use function members
+        instead of data members of InlineTextBox.
+        (WebCore::Position::upstream): Ditto.
+        (WebCore::Position::downstream): Ditto.
+        (WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight): Ditto.
+        (WebCore::Position::inRenderedText): Ditto.
+        (WebCore::Position::isRenderedCharacter): Ditto.
+        (WebCore::searchAheadForBetterMatch): Ditto.
+        (WebCore::Position::getInlineBoxAndOffset): Ditto.
+
+        * dom/Range.cpp: Added include of VisiblePosition.h now that it's no longer
+        included in RenderObject.h.
+
+        * dom/Text.cpp:
+        (WebCore::Text::splitText): Use toRenderText.
+        (WebCore::Text::recalcStyle): Ditto.
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::deleteInsignificantText): Ditto.
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::debugRenderer): Ditto.
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::handleTextNode): Ditto.
+        (WebCore::TextIterator::handleTextBox): Ditto.
+        (WebCore::TextIterator::emitText): Ditto.
+        (WebCore::SimplifiedBackwardsTextIterator::handleTextNode): Ditto.
+
+        * editing/VisiblePosition.cpp: Added include of FloatQuad.h now that it's
+        no longer included in RenderObject.h.
+        * inspector/InspectorController.cpp: Ditto.
+        * page/Frame.cpp: Ditto.
+        * rendering/RenderBox.cpp: Ditto.
+        * rendering/RenderInline.cpp: Ditto.
+        * rendering/RenderPath.cpp: Ditto.
+        * rendering/RenderSVGContainer.cpp: Ditto.
+        * rendering/RenderSVGImage.cpp: Ditto.
+        * rendering/RenderSVGInlineText.cpp: Ditto.
+        * rendering/RenderSVGTSpan.cpp: Ditto.
+        * rendering/RenderSVGText.cpp: Ditto.
+        * rendering/RenderSVGTextPath.cpp: Ditto.
+        * rendering/RenderTableCell.cpp: Ditto.
+        * rendering/RenderView.cpp: Ditto.
+
+        * editing/visible_units.cpp:
+        (WebCore::startPositionForLine): Use function members instead of data
+        members of InlineTextBox.
+        (WebCore::endPositionForLine): Ditto.
+        (WebCore::startOfParagraph): Use toRenderText.
+        (WebCore::endOfParagraph): Ditto.
+
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored): Use toRenderText.
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::placeBoxesHorizontally): Ditto.
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::deleteLine): Ditto.
+        (WebCore::InlineTextBox::extractLine): Ditto.
+        (WebCore::InlineTextBox::attachLine): Ditto.
+        (WebCore::InlineTextBox::placeEllipsisBox): Ditto.
+        (WebCore::InlineTextBox::paintDecoration): Ditto.
+        (WebCore::InlineTextBox::paintCompositionUnderline): Ditto.
+        (WebCore::InlineTextBox::offsetForPosition): Ditto.
+        (WebCore::InlineTextBox::positionForOffset): Ditto.
+
+        * rendering/InlineTextBox.h: Made most members private. Use toRenderText.
+
+        * rendering/RenderArena.cpp:
+        (WebCore::RenderArena::allocate): Use static_cast instead of C-style cast.
+        (WebCore::RenderArena::free): Ditto.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::addContinuationWithOutline): Use ListHashSet<RenderFlow*>
+        instead of RenderFlowSequencedSet.
+        (WebCore::RenderBlock::paintContinuationOutlines): Ditto.
+        (WebCore::stripTrailingSpace): Ditto.
+        (WebCore::RenderBlock::calcInlinePrefWidths): Ditto.
+        (WebCore::RenderBlock::updateFirstLetter): Ditto.
+
+        * rendering/RenderContainer.cpp:
+        (WebCore::RenderContainer::addChild): Use toRenderText.
+
+        * rendering/RenderFlow.cpp:
+        (WebCore::RenderFlow::dirtyLinesFromChangedChild): Use ListHashSet<RenderFlow*>
+        instead of RenderFlowSequencedSet.
+        (WebCore::RenderFlow::paintLines): Ditto.
+
+        * rendering/RenderMenuList.cpp: Removed some unneeded includes.
+
+        * rendering/RenderMenuList.h: Added now-needed forward declaration of RenderText.
+        Made more members private.
+
+        * rendering/RenderObject.cpp: Updated includes.
+        (WebCore::RenderObject::isEditable): Use toRenderText.
+        (WebCore::RenderObject::positionForPoint): Made non-inline so we wouldn't have to
+        include VisiblePosition.h in the header just for this.
+
+        * rendering/RenderObject.h: Removed unneeded includes and forward declarations.
+        Changed special vertical position values to be constants rather than an enum.
+        Eliminated RenderFlowSequencedSet, and changed clients to use ListHashSet<RenderFlow*>.
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::findNextInlineTextBox): Use function members instead of
+        data members of InlineTextBox.
+        (WebCore::RenderText::positionForCoordinates): Ditto.
+        (WebCore::isInlineFlowOrEmptyText): Use toRenderText.
+        (WebCore::RenderText::previousCharacter): Use function members instead of
+        data members of InlineTextBox.
+        (WebCore::RenderText::position): Ditto.
+        (WebCore::RenderText::caretMinOffset): Ditto.
+        (WebCore::RenderText::caretMaxOffset): Ditto.
+        (WebCore::RenderText::caretMaxRenderedOffset): Ditto.
+
+        * rendering/RenderText.h: Added definition of toRenderText.
+
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::textWithHardLineBreaks): Use toRenderText.
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::operator<<): Use toRenderText and toRenderBox.
+        (WebCore::writeTextRun): Ditto.
+        (WebCore::write): Ditto.
+
+        * rendering/bidi.cpp:
+        (WebCore::InlineIterator::increment): Use toRenderText.
+        (WebCore::InlineIterator::current): Ditto.
+        (WebCore::checkMidpoints): Ditto.
+        (WebCore::RenderBlock::computeHorizontalPositionsForLine): Ditto.
+        (WebCore::RenderBlock::layoutInlineChildren): Ditto.
+        (WebCore::RenderBlock::determineStartPosition): Ditto.
+        (WebCore::shouldSkipWhitespaceAfterStartObject): Ditto.
+        (WebCore::RenderBlock::findNextLineBreak): Ditto.
+
 2009-01-25  Thiago Macieira  <thiago.macieira@nokia.com>
 
         Reviewed by Simon Hausmann.
index ad980f4..0ce4170 100644 (file)
@@ -23,7 +23,6 @@
 #include "CharacterData.h"
 
 #include "CString.h"
-#include "Document.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "MutationEvent.h"
@@ -61,7 +60,7 @@ void CharacterData::setData(const String& data, ExceptionCode&)
         detach();
         attach();
     } else if (renderer())
-        static_cast<RenderText*>(renderer())->setText(m_data);
+        toRenderText(renderer())->setText(m_data);
     
     dispatchModifiedEvent(oldStr.get());
     
@@ -89,7 +88,7 @@ void CharacterData::appendData(const String& arg, ExceptionCode&)
         detach();
         attach();
     } else if (renderer())
-        static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, oldStr->length(), 0);
+        toRenderText(renderer())->setTextWithOffset(m_data, oldStr->length(), 0);
     
     dispatchModifiedEvent(oldStr.get());
 }
@@ -110,7 +109,7 @@ void CharacterData::insertData(unsigned offset, const String& arg, ExceptionCode
         detach();
         attach();
     } else if (renderer())
-        static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, 0);
+        toRenderText(renderer())->setTextWithOffset(m_data, offset, 0);
 
     dispatchModifiedEvent(oldStr.get());
     
@@ -139,7 +138,7 @@ void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionCode& e
         detach();
         attach();
     } else if (renderer())
-        static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, count);
+        toRenderText(renderer())->setTextWithOffset(m_data, offset, count);
 
     dispatchModifiedEvent(oldStr.get());
 
@@ -169,7 +168,7 @@ void CharacterData::replaceData(unsigned offset, unsigned count, const String& a
         detach();
         attach();
     } else if (renderer())
-        static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, count);
+        toRenderText(renderer())->setTextWithOffset(m_data, offset, count);
     
     dispatchModifiedEvent(oldStr.get());
     
index 87ac92b..958fc4e 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "ContainerNodeAlgorithms.h"
 #include "DeleteButtonController.h"
-#include "Document.h"
-#include "Editor.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "FloatRect.h"
 #include "FrameView.h"
 #include "InlineTextBox.h"
 #include "MutationEvent.h"
-#include "RenderBox.h"
 #include "RenderTheme.h"
 #include "RootInlineBox.h"
 #include <wtf/CurrentTime.h>
-#include <wtf/Vector.h>
 
 namespace WebCore {
 
@@ -687,13 +683,13 @@ bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const
             return true;
         }
 
-        if (p->element() && p->element() == this && o->isText() && !o->isBR() && !static_cast<RenderText*>(o)->firstTextBox()) {
+        if (p->element() && p->element() == this && o->isText() && !o->isBR() && !toRenderText(o)->firstTextBox()) {
                 // do nothing - skip unrendered whitespace that is a child or next sibling of the anchor
         } else if ((o->isText() && !o->isBR()) || o->isReplaced()) {
             point = o->container()->localToAbsolute();
-            if (o->isText() && static_cast<RenderText *>(o)->firstTextBox()) {
-                point.move(static_cast<RenderText *>(o)->linesBoundingBox().x(),
-                           static_cast<RenderText *>(o)->firstTextBox()->root()->topOverflow());
+            if (o->isText() && toRenderText(o)->firstTextBox()) {
+                point.move(toRenderText(o)->linesBoundingBox().x(),
+                           toRenderText(o)->firstTextBox()->root()->topOverflow());
             } else if (o->isBox()) {
                 RenderBox* box = toRenderBox(o);
                 point.move(box->x(), box->y());
@@ -745,7 +741,7 @@ bool ContainerNode::getLowerRightCorner(FloatPoint& point) const
         if (o->isText() || o->isReplaced()) {
             point = o->container()->localToAbsolute();
             if (o->isText()) {
-                RenderText* text = static_cast<RenderText*>(o);
+                RenderText* text = toRenderText(o);
                 IntRect linesBox = text->linesBoundingBox();
                 point.move(linesBox.x() + linesBox.width(), linesBox.height());
             } else {
index 7a8c54b..faa4a13 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "CSSComputedStyleDeclaration.h"
 #include "CString.h"
 #include "CharacterNames.h"
-#include "Document.h"
-#include "Element.h"
-#include "HTMLNames.h"
 #include "Logging.h"
 #include "PositionIterator.h"
 #include "RenderBlock.h"
 #include "Text.h"
 #include "TextIterator.h"
+#include "VisiblePosition.h"
 #include "htmlediting.h"
 #include "visible_units.h"
 #include <stdio.h>
@@ -54,7 +52,7 @@ static Node *nextRenderedEditable(Node *node)
         RenderObject* renderer = node->renderer();
         if (!renderer)
             continue;
-        if (renderer->inlineBoxWrapper() || renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox())
+        if (renderer->inlineBoxWrapper() || renderer->isText() && toRenderText(renderer)->firstTextBox())
             return node;
     }
     return 0;
@@ -69,7 +67,7 @@ static Node *previousRenderedEditable(Node *node)
         RenderObject* renderer = node->renderer();
         if (!renderer)
             continue;
-        if (renderer->inlineBoxWrapper() || renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox())
+        if (renderer->inlineBoxWrapper() || renderer->isText() && toRenderText(renderer)->firstTextBox())
             return node;
     }
     return 0;
@@ -196,17 +194,17 @@ int Position::renderedOffset() const
         return offset();
                     
     int result = 0;
-    RenderText *textRenderer = static_cast<RenderText *>(node()->renderer());
+    RenderText *textRenderer = toRenderText(node()->renderer());
     for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
-        int start = box->m_start;
-        int end = box->m_start + box->m_len;
+        int start = box->start();
+        int end = box->start() + box->len();
         if (offset() < start)
             return result;
         if (offset() <= end) {
             result += offset() - start;
             return result;
         }
-        result += box->m_len;
+        result += box->len();
     }
     return result;
 }
@@ -366,7 +364,7 @@ Position Position::upstream() const
         }
 
         // return current position if it is in rendered text
-        if (renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox()) {
+        if (renderer->isText() && toRenderText(renderer)->firstTextBox()) {
             if (currentNode != startNode) {
                 // This assertion fires in layout tests in the case-transform.html test because
                 // of a mix-up between offsets in the text in the DOM tree with text in the
@@ -377,7 +375,7 @@ Position Position::upstream() const
             }
 
             unsigned textOffset = currentPos.offsetInLeafNode();
-            RenderText* textRenderer = static_cast<RenderText*>(renderer);
+            RenderText* textRenderer = toRenderText(renderer);
             InlineTextBox* lastTextBox = textRenderer->lastTextBox();
             for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
                 if (textOffset <= box->start() + box->len()) {
@@ -482,14 +480,14 @@ Position Position::downstream() const
         }
 
         // return current position if it is in rendered text
-        if (renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox()) {
+        if (renderer->isText() && toRenderText(renderer)->firstTextBox()) {
             if (currentNode != startNode) {
                 ASSERT(currentPos.atStartOfNode());
                 return Position(currentNode, renderer->caretMinOffset());
             }
 
             unsigned textOffset = currentPos.offsetInLeafNode();
-            RenderText* textRenderer = static_cast<RenderText*>(renderer);
+            RenderText* textRenderer = toRenderText(renderer);
             InlineTextBox* lastTextBox = textRenderer->lastTextBox();
             for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
                 if (textOffset <= box->end()) {
@@ -537,7 +535,7 @@ bool Position::hasRenderedNonAnonymousDescendantsWithHeight(RenderObject* render
     RenderObject* stop = renderer->nextInPreOrderAfterChildren();
     for (RenderObject *o = renderer->firstChild(); o && o != stop; o = o->nextInPreOrder())
         if (o->element()) {
-            if ((o->isText() && static_cast<RenderText*>(o)->linesBoundingBox().height()) ||
+            if ((o->isText() && toRenderText(o)->linesBoundingBox().height()) ||
                 (o->isBox() && toRenderBox(o)->borderBoundingBox().height()))
                 return true;
         }
@@ -586,9 +584,9 @@ bool Position::inRenderedText() const
     if (!renderer)
         return false;
     
-    RenderText *textRenderer = static_cast<RenderText *>(renderer);
+    RenderText *textRenderer = toRenderText(renderer);
     for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
-        if (offset() < box->m_start && !textRenderer->containsReversedText()) {
+        if (offset() < static_cast<int>(box->start()) && !textRenderer->containsReversedText()) {
             // The offset we're looking for is before this node
             // this means the offset must be in content that is
             // not rendered. Return false.
@@ -618,19 +616,19 @@ bool Position::isRenderedCharacter() const
     if (isNull() || !node()->isTextNode())
         return false;
         
-    RenderObject *renderer = node()->renderer();
+    RenderObjectrenderer = node()->renderer();
     if (!renderer)
         return false;
     
-    RenderText *textRenderer = static_cast<RenderText *>(renderer);
-    for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
-        if (offset() < box->m_start && !textRenderer->containsReversedText()) {
+    RenderText* textRenderer = toRenderText(renderer);
+    for (InlineTextBoxbox = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
+        if (offset() < static_cast<int>(box->start()) && !textRenderer->containsReversedText()) {
             // The offset we're looking for is before this node
             // this means the offset must be in content that is
             // not rendered. Return false.
             return false;
         }
-        if (offset() >= box->m_start && offset() < box->m_start + box->m_len)
+        if (offset() >= static_cast<int>(box->start()) && offset() < static_cast<int>(box->start() + box->len()))
             return true;
     }
     
@@ -797,7 +795,7 @@ static InlineTextBox* searchAheadForBetterMatch(RenderObject* renderer)
         if (isNonTextLeafChild(next))
             break;
         if (next->isText()) {
-            for (InlineTextBox* box = static_cast<RenderText*>(next)->firstTextBox(); box; box = box->nextTextBox()) {
+            for (InlineTextBox* box = toRenderText(next)->firstTextBox(); box; box = box->nextTextBox()) {
                 int caretMinOffset = box->caretMinOffset();
                 if (caretMinOffset < minOffset) {
                     match = box;
@@ -818,7 +816,7 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi
         if (!inlineBox || caretOffset > inlineBox->caretMinOffset() && caretOffset < inlineBox->caretMaxOffset())
             return;
     } else {
-        RenderText* textRenderer = static_cast<RenderText*>(renderer);
+        RenderText* textRenderer = toRenderText(renderer);
 
         InlineTextBox* box;
         InlineTextBox* candidate = 0;
index ab1a42d..b5afdd1 100644 (file)
 #include "RangeException.h"
 
 #include "CString.h"
-#include "Document.h"
 #include "DocumentFragment.h"
-#include "ExceptionCode.h"
-#include "HTMLElement.h"
-#include "HTMLNames.h"
 #include "NodeWithIndex.h"
 #include "ProcessingInstruction.h"
-#include "RenderBlock.h"
 #include "Text.h"
 #include "TextIterator.h"
+#include "VisiblePosition.h"
 #include "markup.h"
 #include "visible_units.h"
 #include <stdio.h>
@@ -44,7 +40,6 @@
 namespace WebCore {
 
 using namespace std;
-using namespace HTMLNames;
 
 #ifndef NDEBUG
 static WTF::RefCountedLeakCounter rangeCounter("Range");
index be6dfe8..95fd2f8 100644 (file)
@@ -23,7 +23,6 @@
 #include "Text.h"
 
 #include "CString.h"
-#include "Document.h"
 #include "ExceptionCode.h"
 #include "RenderText.h"
 #include "TextBreakIterator.h"
@@ -81,7 +80,7 @@ PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionCode& ec)
         document()->textNodeSplit(this);
 
     if (renderer())
-        static_cast<RenderText*>(renderer())->setText(m_data);
+        toRenderText(renderer())->setText(m_data);
 
     return newText.release();
 }
@@ -256,7 +255,7 @@ void Text::recalcStyle(StyleChange change)
     if (changed()) {
         if (renderer()) {
             if (renderer()->isText())
-                static_cast<RenderText*>(renderer())->setText(m_data);
+                toRenderText(renderer())->setText(m_data);
         } else {
             if (attached())
                 detach();
index 7914eb6..335f77e 100644 (file)
@@ -52,6 +52,7 @@
 #include "RemoveNodePreservingChildrenCommand.h"
 #include "ReplaceSelectionCommand.h"
 #include "RenderBlock.h"
+#include "RenderText.h"
 #include "SetNodeAttributeCommand.h"
 #include "SplitElementCommand.h"
 #include "SplitTextNodeCommand.h"
@@ -465,7 +466,7 @@ void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un
     if (!textNode || start >= end)
         return;
 
-    RenderText* textRenderer = static_cast<RenderText*>(textNode->renderer());
+    RenderText* textRenderer = toRenderText(textNode->renderer());
     if (!textRenderer)
         return;
 
@@ -487,12 +488,12 @@ void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un
     // This loop structure works to process all gaps preceding a box,
     // and also will look at the gap after the last box.
     while (prevBox || box) {
-        unsigned gapStart = prevBox ? prevBox->m_start + prevBox->m_len : 0;
+        unsigned gapStart = prevBox ? prevBox->start() + prevBox->len() : 0;
         if (end < gapStart)
             // No more chance for any intersections
             break;
 
-        unsigned gapEnd = box ? box->m_start : length;
+        unsigned gapEnd = box ? box->start() : length;
         bool indicesIntersect = start <= gapEnd && end >= gapStart;
         int gapLen = gapEnd - gapStart;
         if (indicesIntersect && gapLen > 0) {
index 4cc7506..67f675e 100644 (file)
@@ -35,6 +35,7 @@
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "FocusController.h"
+#include "FloatQuad.h"
 #include "Frame.h"
 #include "FrameTree.h"
 #include "FrameView.h"
@@ -918,7 +919,7 @@ void SelectionController::debugRenderer(RenderObject *r, bool selected) const
         fprintf(stderr, "%s%s\n", selected ? "==> " : "    ", element->localName().string().utf8().data());
     }
     else if (r->isText()) {
-        RenderText* textRenderer = static_cast<RenderText*>(r);
+        RenderText* textRenderer = toRenderText(r);
         if (textRenderer->textLength() == 0 || !textRenderer->firstTextBox()) {
             fprintf(stderr, "%s#text (empty)\n", selected ? "==> " : "    ");
             return;
@@ -936,7 +937,7 @@ void SelectionController::debugRenderer(RenderObject *r, bool selected) const
                 
             int pos;
             InlineTextBox *box = textRenderer->findNextInlineTextBox(offset, pos);
-            text = text.substring(box->m_start, box->m_len);
+            text = text.substring(box->start(), box->len());
             
             String show;
             int mid = max / 2;
index dd9f9ab..f617889 100644 (file)
@@ -38,6 +38,7 @@
 #include "RenderTableCell.h"
 #include "RenderTableRow.h"
 #include "RenderTextControl.h"
+#include "VisiblePosition.h"
 #include "visible_units.h"
 
 #if USE(ICU_UNICODE) && !UCONFIG_NO_COLLATION
@@ -285,7 +286,7 @@ static inline bool compareBoxStart(const InlineTextBox *first, const InlineTextB
 
 bool TextIterator::handleTextNode()
 {
-    RenderText* renderer = static_cast<RenderText*>(m_node->renderer());
+    RenderText* renderer = toRenderText(m_node->renderer());
     if (renderer->style()->visibility() != VISIBLE)
         return false;
         
@@ -332,12 +333,12 @@ bool TextIterator::handleTextNode()
 
 void TextIterator::handleTextBox()
 {    
-    RenderText *renderer = static_cast<RenderText *>(m_node->renderer());
+    RenderText *renderer = toRenderText(m_node->renderer());
     String str = renderer->text();
     int start = m_offset;
     int end = (m_node == m_endContainer) ? m_endOffset : INT_MAX;
     while (m_textBox) {
-        int textBoxStart = m_textBox->m_start;
+        int textBoxStart = m_textBox->start();
         int runStart = max(textBoxStart, start);
 
         // Check for collapsed space at the start of this run.
@@ -354,7 +355,7 @@ void TextIterator::handleTextBox()
                 emitCharacter(' ', m_node, 0, runStart, runStart);
             return;
         }
-        int textBoxEnd = textBoxStart + m_textBox->m_len;
+        int textBoxEnd = textBoxStart + m_textBox->len();
         int runEnd = min(textBoxEnd, end);
         
         // Determine what the next text box will be, but don't advance yet
@@ -387,7 +388,7 @@ void TextIterator::handleTextBox()
                 return;
 
             // Advance and return
-            int nextRunStart = nextTextBox ? nextTextBox->m_start : str.length();
+            int nextRunStart = nextTextBox ? nextTextBox->start() : str.length();
             if (nextRunStart > runEnd)
                 m_lastTextNodeEndedWithCollapsedSpace = true; // collapsed space between runs or at the end
             m_textBox = nextTextBox;
@@ -712,7 +713,7 @@ void TextIterator::emitCharacter(UChar c, Node *textNode, Node *offsetBaseNode,
 
 void TextIterator::emitText(Node* textNode, int textStartOffset, int textEndOffset)
 {
-    RenderText* renderer = static_cast<RenderText*>(m_node->renderer());
+    RenderText* renderer = toRenderText(m_node->renderer());
     String str = renderer->text();
     ASSERT(str.characters());
 
@@ -895,7 +896,7 @@ bool SimplifiedBackwardsTextIterator::handleTextNode()
 {
     m_lastTextNode = m_node;
 
-    RenderText *renderer = static_cast<RenderText *>(m_node->renderer());
+    RenderText *renderer = toRenderText(m_node->renderer());
     String str = renderer->text();
 
     if (!renderer->firstTextBox() && str.length() > 0)
index 9222005..3d771c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,7 +29,7 @@
 #include "CString.h"
 #include "Document.h"
 #include "Element.h"
-#include "FloatRect.h"
+#include "FloatQuad.h"
 #include "HTMLNames.h"
 #include "InlineTextBox.h"
 #include "Logging.h"
index d0715fb..a50503d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@
 #include "TextBoundaries.h"
 #include "TextBreakIterator.h"
 #include "TextIterator.h"
+#include "VisiblePosition.h"
 #include "htmlediting.h"
 
 namespace WebCore {
@@ -314,7 +315,7 @@ static VisiblePosition startPositionForLine(const VisiblePosition& c)
     int startOffset = 0;
     if (startBox->isInlineTextBox()) {
         InlineTextBox *startTextBox = static_cast<InlineTextBox *>(startBox);
-        startOffset = startTextBox->m_start;
+        startOffset = startTextBox->start();
     }
   
     VisiblePosition visPos = VisiblePosition(startNode, startOffset, DOWNSTREAM);
@@ -383,9 +384,9 @@ static VisiblePosition endPositionForLine(const VisiblePosition& c)
         endOffset = 0;
     } else if (endBox->isInlineTextBox()) {
         InlineTextBox *endTextBox = static_cast<InlineTextBox *>(endBox);
-        endOffset = endTextBox->m_start;
+        endOffset = endTextBox->start();
         if (!endTextBox->isLineBreak())
-            endOffset += endTextBox->m_len;
+            endOffset += endTextBox->len();
     }
     
     return VisiblePosition(endNode, endOffset, VP_UPSTREAM_IF_POSSIBLE);
@@ -706,8 +707,8 @@ VisiblePosition startOfParagraph(const VisiblePosition &c)
             
         if (r->isText()) {
             if (style->preserveNewline()) {
-                const UChar* chars = static_cast<RenderText*>(r)->characters();
-                int i = static_cast<RenderText*>(r)->textLength();
+                const UChar* chars = toRenderText(r)->characters();
+                int i = toRenderText(r)->textLength();
                 int o = offset;
                 if (n == startNode && o < i)
                     i = max(0, o);
@@ -771,9 +772,9 @@ VisiblePosition endOfParagraph(const VisiblePosition &c)
         // FIXME: We avoid returning a position where the renderer can't accept the caret.
         // We should probably do this in other cases such as startOfParagraph.
         if (r->isText() && r->caretMaxRenderedOffset() > 0) {
-            int length = static_cast<RenderText*>(r)->textLength();
+            int length = toRenderText(r)->textLength();
             if (style->preserveNewline()) {
-                const UChar* chars = static_cast<RenderText*>(r)->characters();
+                const UChar* chars = toRenderText(r)->characters();
                 int o = n == startNode ? offset : 0;
                 for (int i = o; i < length; ++i)
                     if (chars[i] == '\n')
index cec41cd..5cdc368 100644 (file)
@@ -39,6 +39,7 @@
 #include "DocumentLoader.h"
 #include "Element.h"
 #include "FloatConversion.h"
+#include "FloatQuad.h"
 #include "FloatRect.h"
 #include "Frame.h"
 #include "FrameLoader.h"
index f5e9e9f..5cdc7b4 100644 (file)
@@ -61,6 +61,7 @@
 #include "RenderListBox.h"
 #include "RenderListMarker.h"
 #include "RenderMenuList.h"
+#include "RenderText.h"
 #include "RenderTextControl.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
@@ -1142,7 +1143,7 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
         if (parentObjectUnignored()->ariaRoleAttribute() == MenuItemRole ||
             parentObjectUnignored()->ariaRoleAttribute() == MenuButtonRole)
             return true;
-         return m_renderer->isBR() || !static_cast<RenderText*>(m_renderer)->firstTextBox();
+         return m_renderer->isBR() || !toRenderText(m_renderer)->firstTextBox();
     }
     
     if (isHeading())
index 4860def..910fcbd 100644 (file)
@@ -42,6 +42,7 @@
 #include "EditorClient.h"
 #include "EventNames.h"
 #include "FocusController.h"
+#include "FloatQuad.h"
 #include "FrameLoader.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
index 79a57c5..67eb762 100644 (file)
@@ -289,7 +289,7 @@ int InlineFlowBox::placeBoxesHorizontally(int x, int& leftPosition, int& rightPo
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
         if (curr->object()->isText()) {
             InlineTextBox* text = static_cast<InlineTextBox*>(curr);
-            RenderText* rt = static_cast<RenderText*>(text->object());
+            RenderText* rt = toRenderText(text->object());
             if (rt->textLength()) {
                 if (needsWordSpacing && isSpaceOrNewline(rt->characters()[text->start()]))
                     x += rt->style(m_firstLine)->font().wordSpacing();
index cbee117..ca965e9 100644 (file)
@@ -108,7 +108,7 @@ IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos)
 
 void InlineTextBox::deleteLine(RenderArena* arena)
 {
-    static_cast<RenderText*>(m_object)->removeTextBox(this);
+    toRenderText(m_object)->removeTextBox(this);
     destroy(arena);
 }
 
@@ -117,7 +117,7 @@ void InlineTextBox::extractLine()
     if (m_extracted)
         return;
 
-    static_cast<RenderText*>(m_object)->extractTextBox(this);
+    toRenderText(m_object)->extractTextBox(this);
 }
 
 void InlineTextBox::attachLine()
@@ -125,7 +125,7 @@ void InlineTextBox::attachLine()
     if (!m_extracted)
         return;
     
-    static_cast<RenderText*>(m_object)->attachTextBox(this);
+    toRenderText(m_object)->attachTextBox(this);
 }
 
 int InlineTextBox::placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth, bool& foundBox)
@@ -162,7 +162,7 @@ int InlineTextBox::placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth,
             
             // Set the truncation index on the text run.  The ellipsis needs to be placed just after the last visible character.
             m_truncation = offset;
-            return m_x + static_cast<RenderText*>(m_object)->width(m_start, offset, textPos(), m_firstLine);
+            return m_x + toRenderText(m_object)->width(m_start, offset, textPos(), m_firstLine);
         }
     }
     else {
@@ -572,7 +572,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
         return;
     
     int width = (m_truncation == cNoTruncation) ? m_width
-        : static_cast<RenderText*>(m_object)->width(m_start, m_truncation, textPos(), m_firstLine);
+        : toRenderText(m_object)->width(m_start, m_truncation, textPos(), m_firstLine);
     
     // Get the text decoration colors.
     Color underline, overline, linethrough;
@@ -797,7 +797,7 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int
     if (paintStart <= underline.startOffset) {
         paintStart = underline.startOffset;
         useWholeWidth = false;
-        start = static_cast<RenderText*>(m_object)->width(m_start, paintStart - m_start, textPos(), m_firstLine);
+        start = toRenderText(m_object)->width(m_start, paintStart - m_start, textPos(), m_firstLine);
     }
     if (paintEnd != underline.endOffset) {      // end points at the last char, not past it
         paintEnd = min(paintEnd, (unsigned)underline.endOffset);
@@ -808,7 +808,7 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int
         useWholeWidth = false;
     }
     if (!useWholeWidth) {
-        width = static_cast<RenderText*>(m_object)->width(paintStart, paintEnd - paintStart, textPos() + start, m_firstLine);
+        width = toRenderText(m_object)->width(paintStart, paintEnd - paintStart, textPos() + start, m_firstLine);
     }
 
     // Thick marked text underlines are 2px thick as long as there is room for the 2px line under the baseline.
@@ -858,7 +858,7 @@ int InlineTextBox::offsetForPosition(int _x, bool includePartialGlyphs) const
     if (isLineBreak())
         return 0;
 
-    RenderText* text = static_cast<RenderText*>(m_object);
+    RenderText* text = toRenderText(m_object);
     RenderStyle *style = text->style(m_firstLine);
     const Font* f = &style->font();
     return f->offsetForPosition(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || style->visuallyOrdered()),
@@ -873,7 +873,7 @@ int InlineTextBox::positionForOffset(int offset) const
     if (isLineBreak())
         return m_x;
 
-    RenderText* text = static_cast<RenderText*>(m_object);
+    RenderText* text = toRenderText(m_object);
     const Font& f = text->style(m_firstLine)->font();
     int from = direction() == RTL ? offset - m_start : 0;
     int to = direction() == RTL ? m_len : offset - m_start;
index 99c511f..0c2dd8a 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * (C) 1999 Lars Knoll (knoll@kde.org)
  * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #ifndef InlineTextBox_h
 #define InlineTextBox_h
 
-#include "DocumentMarker.h"
 #include "InlineRunBox.h"
-#include "RenderText.h"
+#include "RenderText.h" // so textObject() can be inline
 
 namespace WebCore {
 
+struct CompositionUnderline;
+
 const unsigned short cNoTruncation = USHRT_MAX;
 const unsigned short cFullTruncation = USHRT_MAX - 1;
 
-class String;
-class StringImpl;
-class HitTestResult;
-class Position;
-
-struct CompositionUnderline;
-
 // Helper functions shared by InlineTextBox / SVGRootInlineBox
 void updateGraphicsContext(GraphicsContext* context, const Color& fillColor, const Color& strokeColor, float strokeThickness);
 Color correctedTextColor(Color textColor, Color backgroundColor);
@@ -67,46 +59,61 @@ public:
 
     void offsetRun(int d) { m_start += d; }
 
+private:
     virtual int selectionTop();
     virtual int selectionHeight();
 
+public:
     virtual IntRect selectionRect(int absx, int absy, int startPos, int endPos);
     bool isSelected(int startPos, int endPos) const;
     void selectionStartEnd(int& sPos, int& ePos);
 
+private:
     virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
 
+public:
     RenderText* textObject() const;
 
+private:
     virtual void deleteLine(RenderArena*);
     virtual void extractLine();
     virtual void attachLine();
 
+public:
     virtual RenderObject::SelectionState selectionState();
 
+private:
     virtual void clearTruncation() { m_truncation = cNoTruncation; }
     virtual int placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth, bool& foundBox);
 
+public:
     virtual bool isLineBreak() const;
 
     void setSpaceAdd(int add) { m_width -= m_toAdd; m_toAdd = add; m_width += m_toAdd; }
-    int spaceAdd() { return m_toAdd; }
 
+private:
     virtual bool isInlineTextBox() { return true; }    
+
+public:
     virtual bool isText() const { return m_treatAsText; }
     void setIsText(bool b) { m_treatAsText = b; }
 
     virtual int caretMinOffset() const;
     virtual int caretMaxOffset() const;
+
+private:
     virtual unsigned caretMaxRenderedOffset() const;
 
     int textPos() const;
+
+public:
     virtual int offsetForPosition(int x, bool includePartialGlyphs = true) const;
     virtual int positionForOffset(int offset) const;
 
     bool containsCaretOffset(int offset) const; // false for offset after line break
 
+private:
     int m_start;
     unsigned short m_len;
 
@@ -122,16 +129,15 @@ protected:
 #endif
 
 private:
-    void paintDecoration(GraphicsContext*, int tx, int ty, int decoration, ShadowData* shadow);
+    void paintDecoration(GraphicsContext*, int tx, int ty, int decoration, ShadowData*);
     void paintSelection(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&);
     void paintSpellingOrGrammarMarker(GraphicsContext*, int tx, int ty, DocumentMarker, RenderStyle*, const Font&, bool grammar);
     void paintTextMatchMarker(GraphicsContext*, int tx, int ty, DocumentMarker, RenderStyle*, const Font&);
-    friend class RenderText;
 };
 
 inline RenderText* InlineTextBox::textObject() const
 {
-    return static_cast<RenderText*>(m_object);
+    return toRenderText(m_object);
 }
 
 } // namespace WebCore
index 69d08a5..b7bfe4d 100644 (file)
@@ -76,7 +76,7 @@ void* RenderArena::allocate(size_t size)
     // Use standard malloc so that memory debugging tools work.
     ASSERT(this);
     void* block = ::malloc(sizeof(RenderArenaDebugHeader) + size);
-    RenderArenaDebugHeader* header = (RenderArenaDebugHeader*)block;
+    RenderArenaDebugHeader* header = static_cast<RenderArenaDebugHeader*>(block);
     header->arena = this;
     header->size = size;
     header->signature = signature;
@@ -112,7 +112,7 @@ void RenderArena::free(size_t size, void* ptr)
 {
 #ifndef NDEBUG
     // Use standard free so that memory debugging tools work.
-    RenderArenaDebugHeader* header = (RenderArenaDebugHeader*)ptr - 1;
+    RenderArenaDebugHeader* header = static_cast<RenderArenaDebugHeader*>(ptr) - 1;
     ASSERT(header->signature == signature);
     ASSERT(header->size == size);
     ASSERT(header->arena == this);
index eb07770..c81bde2 100644 (file)
@@ -72,7 +72,7 @@ static PercentHeightDescendantsMap* gPercentHeightDescendantsMap = 0;
 typedef WTF::HashMap<const RenderBox*, HashSet<RenderBlock*>*> PercentHeightContainerMap;
 static PercentHeightContainerMap* gPercentHeightContainerMap = 0;
     
-typedef WTF::HashMap<RenderBlock*, RenderFlowSequencedSet*> ContinuationOutlineTableMap;
+typedef WTF::HashMap<RenderBlock*, ListHashSet<RenderFlow*>*> ContinuationOutlineTableMap;
 
 // Our MarginInfo state used when laying out block children.
 RenderBlock::MarginInfo::MarginInfo(RenderBlock* block, int top, int bottom)
@@ -1824,9 +1824,9 @@ void RenderBlock::addContinuationWithOutline(RenderFlow* flow)
     ASSERT(!flow->layer());
     
     ContinuationOutlineTableMap* table = continuationOutlineTable();
-    RenderFlowSequencedSet* continuations = table->get(this);
+    ListHashSet<RenderFlow*>* continuations = table->get(this);
     if (!continuations) {
-        continuations = new RenderFlowSequencedSet;
+        continuations = new ListHashSet<RenderFlow*>;
         table->set(this, continuations);
     }
     
@@ -1839,13 +1839,13 @@ void RenderBlock::paintContinuationOutlines(PaintInfo& info, int tx, int ty)
     if (table->isEmpty())
         return;
         
-    RenderFlowSequencedSet* continuations = table->get(this);
+    ListHashSet<RenderFlow*>* continuations = table->get(this);
     if (!continuations)
         return;
         
     // Paint each continuation outline.
-    RenderFlowSequencedSet::iterator end = continuations->end();
-    for (RenderFlowSequencedSet::iterator it = continuations->begin(); it != end; ++it) {
+    ListHashSet<RenderFlow*>::iterator end = continuations->end();
+    for (ListHashSet<RenderFlow*>::iterator it = continuations->begin(); it != end; ++it) {
         // Need to add in the coordinates of the intervening blocks.
         RenderFlow* flow = *it;
         RenderBlock* block = flow->containingBlock();
@@ -3843,7 +3843,7 @@ static inline void stripTrailingSpace(int& inlineMax, int& inlineMin,
 {
     if (trailingSpaceChild && trailingSpaceChild->isText()) {
         // Collapse away the trailing space at the end of a block.
-        RenderText* t = static_cast<RenderText*>(trailingSpaceChild);
+        RenderText* t = toRenderText(trailingSpaceChild);
         const UChar space = ' ';
         const Font& font = t->style()->font(); // FIXME: This ignores first-line.
         int spaceWidth = font.width(TextRun(&space, 1));
@@ -4009,7 +4009,7 @@ void RenderBlock::calcInlinePrefWidths()
                 }
             } else if (child->isText()) {
                 // Case (3). Text.
-                RenderText* t = static_cast<RenderText *>(child);
+                RenderText* t = toRenderText(child);
 
                 if (t->isWordBreak()) {
                     m_minPrefWidth = max(inlineMin, m_minPrefWidth);
@@ -4412,7 +4412,7 @@ void RenderBlock::updateFirstLetter()
         // adding and removing children of firstLetterContainer.
         view()->disableLayoutState();
 
-        RenderText* textObj = static_cast<RenderText*>(currChild);
+        RenderText* textObj = toRenderText(currChild);
         
         // Create our pseudo style now that we have our firstLetterContainer determined.
         RenderStyle* pseudoStyle = firstLetterBlock->getCachedPseudoStyle(RenderStyle::FIRST_LETTER,
index ceccf3c..461776a 100644 (file)
@@ -33,6 +33,7 @@
 #include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "ImageBuffer.h"
+#include "FloatQuad.h"
 #include "Frame.h"
 #include "Page.h"
 #include "RenderArena.h"
index f30adec..57a9073 100644 (file)
@@ -127,9 +127,9 @@ void RenderContainer::addChild(RenderObject* newChild, RenderObject* beforeChild
     }
     
     if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) {
-        RefPtr<StringImpl> textToTransform = static_cast<RenderText*>(newChild)->originalText();
+        RefPtr<StringImpl> textToTransform = toRenderText(newChild)->originalText();
         if (textToTransform)
-            static_cast<RenderText*>(newChild)->setText(textToTransform.release(), true);
+            toRenderText(newChild)->setText(textToTransform.release(), true);
     }
 }
 
index 8c9fc6c..10b04dc 100644 (file)
@@ -272,7 +272,7 @@ void RenderFlow::dirtyLinesFromChangedChild(RenderObject* child)
             if (wrapper)
                 box = wrapper->root();
         } else if (curr->isText()) {
-            InlineTextBox* textBox = static_cast<RenderText*>(curr)->lastTextBox();
+            InlineTextBox* textBox = toRenderText(curr)->lastTextBox();
             if (textBox)
                 box = textBox->root();
         } else if (curr->isInlineFlow()) {
@@ -400,7 +400,7 @@ void RenderFlow::paintLines(PaintInfo& paintInfo, int tx, int ty)
         return;
 
     PaintInfo info(paintInfo);
-    RenderFlowSequencedSet outlineObjects;
+    ListHashSet<RenderFlow*> outlineObjects;
     info.outlineObjects = &outlineObjects;
 
     // See if our root lines intersect with the dirty rect.  If so, then we paint
@@ -435,8 +435,8 @@ void RenderFlow::paintLines(PaintInfo& paintInfo, int tx, int ty)
     }
 
     if (info.phase == PaintPhaseOutline || info.phase == PaintPhaseSelfOutline || info.phase == PaintPhaseChildOutlines) {
-        RenderFlowSequencedSet::iterator end = info.outlineObjects->end();
-        for (RenderFlowSequencedSet::iterator it = info.outlineObjects->begin(); it != end; ++it) {
+        ListHashSet<RenderFlow*>::iterator end = info.outlineObjects->end();
+        for (ListHashSet<RenderFlow*>::iterator it = info.outlineObjects->begin(); it != end; ++it) {
             RenderFlow* flow = *it;
             flow->paintOutline(info.context, tx, ty);
         }
index 5357e51..90f1926 100644 (file)
@@ -25,7 +25,7 @@
 #include "config.h"
 #include "RenderInline.h"
 
-#include "Document.h"
+#include "FloatQuad.h"
 #include "RenderArena.h"
 #include "RenderBlock.h"
 #include "VisiblePosition.h"
index 19f8b75..5b869ba 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * This file is part of the select element renderer in WebCore.
  *
  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
 #include "RenderMenuList.h"
 
 #include "CSSStyleSelector.h"
-#include "Document.h"
-#include "FontSelector.h"
 #include "FrameView.h"
-#include "GraphicsContext.h"
 #include "HTMLNames.h"
 #include "HTMLSelectElement.h"
 #include "OptionElement.h"
@@ -36,9 +33,7 @@
 #include "PopupMenu.h"
 #include "RenderBR.h"
 #include "RenderScrollbar.h"
-#include "RenderText.h"
 #include "RenderTheme.h"
-#include "NodeRenderStyle.h"
 #include <math.h>
 
 using namespace std;
index f31ef32..a7530fa 100644 (file)
@@ -23,8 +23,8 @@
 #ifndef RenderMenuList_h
 #define RenderMenuList_h
 
-#include "RenderFlexibleBox.h"
 #include "PopupMenuClient.h"
+#include "RenderFlexibleBox.h"
 
 #if PLATFORM(MAC)
 #define POPUP_MENU_PULLS_DOWN 0
@@ -36,6 +36,7 @@ namespace WebCore {
 
 class HTMLSelectElement;
 class PopupMenu;
+class RenderText;
 
 class RenderMenuList : public RenderFlexibleBox, private PopupMenuClient {
 public:
@@ -44,6 +45,7 @@ public:
     
     HTMLSelectElement* selectElement();
 
+private:
     virtual bool isMenuList() const { return true; }
 
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
@@ -60,6 +62,7 @@ public:
 
     virtual void calcPrefWidths();
 
+public:
     bool popupIsVisible() const { return m_popupIsVisible; }
     void showPopup();
     void hidePopup();
@@ -68,10 +71,9 @@ public:
 
     String text() const;
 
-protected:
+private:
     virtual void styleDidChange(RenderStyle::Diff, const RenderStyle* oldStyle);
 
-private:
     // PopupMenuClient methods
     virtual String itemText(unsigned listIndex) const;
     virtual bool itemIsEnabled(unsigned listIndex) const;
index bb3a6ca..4c64324 100644 (file)
 #include "RenderObject.h"
 
 #include "AXObjectCache.h"
-#include "TransformationMatrix.h"
-#include "AnimationController.h"
 #include "CSSStyleSelector.h"
-#include "CachedImage.h"
-#include "Chrome.h"
-#include "Document.h"
-#include "Element.h"
-#include "EventHandler.h"
-#include "FloatRect.h"
-#include "Frame.h"
+#include "FloatQuad.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
 #include "HTMLNames.h"
-#include "HTMLOListElement.h"
-#include "HitTestRequest.h"
 #include "HitTestResult.h"
-#include "KURL.h"
 #include "Page.h"
-#include "PlatformScreen.h"
-#include "Position.h"
 #include "RenderArena.h"
 #include "RenderCounter.h"
 #include "RenderFlexibleBox.h"
 #include "RenderTableCell.h"
 #include "RenderTableCol.h"
 #include "RenderTableRow.h"
-#include "RenderText.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
-#include "SelectionController.h"
-#include "TextResourceDecoder.h"
 #include <algorithm>
 #include <stdio.h>
 #include <wtf/RefCountedLeakCounter.h>
@@ -352,7 +336,7 @@ bool RenderObject::isEditable() const
 {
     RenderText* textRenderer = 0;
     if (isText())
-        textRenderer = static_cast<RenderText*>(const_cast<RenderObject*>(this));
+        textRenderer = toRenderText(const_cast<RenderObject*>(this));
 
     return style()->visibility() == VISIBLE &&
         element() && element()->isContentEditable() &&
@@ -2358,6 +2342,11 @@ VisiblePosition RenderObject::positionForCoordinates(int, int)
     return VisiblePosition(element(), caretMinOffset(), DOWNSTREAM);
 }
 
+VisiblePosition RenderObject::positionForPoint(const IntPoint& point)
+{
+    return positionForCoordinates(point.x(), point.y());
+}
+
 void RenderObject::updateDragState(bool dragOn)
 {
     bool valueChanged = (dragOn != m_isDragging);
index 1b5a63b..6ff33d8 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
  *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 #include "CachedResourceClient.h"
 #include "Document.h"
-#include "FloatQuad.h"
 #include "RenderStyle.h"
-#include "VisiblePosition.h"
-#include <wtf/HashMap.h>
 
 namespace WebCore {
 
-class TransformationMatrix;
 class AnimationController;
-class Color;
-class Document;
-class Element;
-class Event;
-class FloatRect;
-class FrameView;
-class HTMLAreaElement;
 class HitTestResult;
 class InlineBox;
 class InlineFlowBox;
-class Position;
-class RenderArena;
 class RenderBlock;
-class RenderBox;
 class RenderFlow;
-class RenderFrameSet;
 class RenderLayer;
-class RenderTable;
-class RenderText;
-class RenderView;
-class String;
-
-struct HitTestRequest;
+class VisiblePosition;
 
 /*
  *  The painting of a layer occurs in three distinct phases.  Each phase involves
@@ -104,11 +84,10 @@ enum HitTestAction {
     HitTestForeground
 };
 
-enum VerticalPositionHint {
-    PositionTop = -0x7fffffff,
-    PositionBottom = 0x7fffffff,
-    PositionUndefined = static_cast<int>(0x80000000)
-};
+// Values for verticalPosition.
+const int PositionTop = -0x7fffffff;
+const int PositionBottom = 0x7fffffff;
+const int PositionUndefined = 0x80000000;
 
 #if ENABLE(DASHBOARD_SUPPORT)
 struct DashboardRegionValue {
@@ -128,10 +107,6 @@ struct DashboardRegionValue {
 };
 #endif
 
-// FIXME: This should be a HashSequencedSet, but we don't have that data structure yet.
-// This means the paint order of outlines will be wrong, although this is a minor issue.
-typedef HashSet<RenderFlow*> RenderFlowSequencedSet;
-
 // Base class for all rendering tree objects.
 class RenderObject : public CachedResourceClient {
     friend class RenderContainer;
@@ -291,7 +266,6 @@ public:
     virtual bool isTextField() const { return false; }
     virtual bool isWidget() const { return false; }
 
-
     bool isRoot() const { return document()->documentElement() == node(); }
     bool isBody() const;
     bool isHR() const;
@@ -442,7 +416,7 @@ public:
      */
     struct PaintInfo {
         PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceBlackText,
-                  RenderObject* newPaintingRoot, RenderFlowSequencedSet* newOutlineObjects)
+                  RenderObject* newPaintingRoot, ListHashSet<RenderFlow*>* newOutlineObjects)
             : context(newContext)
             , rect(newRect)
             , phase(newPhase)
@@ -457,7 +431,7 @@ public:
         PaintPhase phase;
         bool forceBlackText;
         RenderObject* paintingRoot; // used to draw just one element and its visual kids
-        RenderFlowSequencedSet* outlineObjects; // used to list outlines that should be painted by a block with inline children
+        ListHashSet<RenderFlow*>* outlineObjects; // used to list outlines that should be painted by a block with inline children
     };
 
     virtual void paint(PaintInfo&, int tx, int ty);
@@ -472,7 +446,6 @@ public:
                                         int /*clipY*/, int /*clipH*/, int /*tx*/, int /*ty*/, int /*width*/, int /*height*/,
                                         InlineFlowBox* = 0, CompositeOperator = CompositeSourceOver) { }
 
-    
     /*
      * Calculates the actual width of the object (only for non inline
      * objects)
@@ -514,7 +487,7 @@ public:
     void updateHitTestResult(HitTestResult&, const IntPoint&);
 
     virtual VisiblePosition positionForCoordinates(int x, int y);
-    VisiblePosition positionForPoint(const IntPoint& point) { return positionForCoordinates(point.x(), point.y()); }
+    VisiblePosition positionForPoint(const IntPoint&);
 
     virtual void dirtyLinesFromChangedChild(RenderObject*);
 
@@ -562,8 +535,8 @@ public:
     IntRect absoluteBoundingBoxRect(bool useTransforms = false);
 
     // Build an array of quads in absolute coords for line boxes
-    virtual void collectAbsoluteLineBoxQuads(Vector<FloatQuad>&, unsigned /*startOffset*/ = 0, unsigned /*endOffset*/ = UINT_MAX, bool /*useSelectionHeight*/ = false) { };
-    virtual void absoluteQuads(Vector<FloatQuad>&, bool /*topLevel*/ = true) { };
+    virtual void collectAbsoluteLineBoxQuads(Vector<FloatQuad>&, unsigned /*startOffset*/ = 0, unsigned /*endOffset*/ = UINT_MAX, bool /*useSelectionHeight*/ = false) { }
+    virtual void absoluteQuads(Vector<FloatQuad>&, bool /*topLevel*/ = true) { }
 
     // the rect that will be painted if this object is passed as the paintingRoot
     IntRect paintingRootRect(IntRect& topLevelRect);
index e87205e..985d427 100644 (file)
@@ -26,9 +26,8 @@
 #if ENABLE(SVG)
 #include "RenderPath.h"
 
-#include <math.h>
-
 #include "FloatPoint.h"
+#include "FloatQuad.h"
 #include "GraphicsContext.h"
 #include "PointerEventsHitRules.h"
 #include "RenderSVGContainer.h"
@@ -41,7 +40,6 @@
 #include "SVGStyledTransformableElement.h"
 #include "SVGTransformList.h"
 #include "SVGURIReference.h"
-
 #include <wtf/MathExtras.h>
 
 namespace WebCore {
index 84834dc..8d7331a 100644 (file)
@@ -27,6 +27,7 @@
 #include "RenderSVGContainer.h"
 
 #include "AXObjectCache.h"
+#include "FloatQuad.h"
 #include "GraphicsContext.h"
 #include "RenderView.h"
 #include "SVGRenderSupport.h"
index 767feed..8e68562 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "Attr.h"
 #include "FloatConversion.h"
+#include "FloatQuad.h"
 #include "GraphicsContext.h"
 #include "PointerEventsHitRules.h"
 #include "SVGImageElement.h"
index 88ff4a3..215e9fe 100644 (file)
 #include "RenderSVGInlineText.h"
 
 #include "FloatConversion.h"
+#include "FloatQuad.h"
 #include "RenderBlock.h"
 #include "RenderSVGRoot.h"
 #include "SVGInlineTextBox.h"
 #include "SVGRootInlineBox.h"
+#include "VisiblePosition.h"
 
 namespace WebCore {
 
index 8c6c360..49c45df 100644 (file)
@@ -26,7 +26,7 @@
 #if ENABLE(SVG)
 #include "RenderSVGTSpan.h"
 
-#include "FloatRect.h"
+#include "FloatQuad.h"
 #include "RenderBlock.h"
 #include "SVGInlineTextBox.h"
 #include "SVGRootInlineBox.h"
index 52ed027..07879f9 100644 (file)
 #include "RenderSVGText.h"
 
 #include "FloatConversion.h"
+#include "FloatQuad.h"
 #include "GraphicsContext.h"
 #include "PointerEventsHitRules.h"
 #include "RenderSVGRoot.h"
-#include "SimpleFontData.h"
 #include "SVGLengthList.h"
 #include "SVGResourceFilter.h"
 #include "SVGRootInlineBox.h"
 #include "SVGTextElement.h"
 #include "SVGTransformList.h"
 #include "SVGURIReference.h"
+#include "SimpleFontData.h"
 
 namespace WebCore {
 
index a3a9070..2d2894f 100644 (file)
@@ -25,7 +25,7 @@
 #if ENABLE(SVG)
 #include "RenderSVGTextPath.h"
 
-#include "FloatRect.h"
+#include "FloatQuad.h"
 #include "RenderBlock.h"
 #include "SVGInlineTextBox.h"
 #include "SVGPathElement.h"
index 2e0e045..c86954a 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (C) 1997 Martin Jones (mjones@kde.org)
  *           (C) 1997 Torben Weis (weis@kde.org)
  *           (C) 1998 Waldo Bastian (bastian@kde.org)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "RenderTableCell.h"
 
+#include "FloatQuad.h"
 #include "GraphicsContext.h"
 #include "HTMLNames.h"
 #include "HTMLTableCellElement.h"
index 33317d5..5eb573f 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * (C) 1999 Lars Knoll (knoll@kde.org)
  * (C) 2000 Dirk Mueller (mueller@kde.org)
  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
@@ -26,6 +26,7 @@
 #include "RenderText.h"
 
 #include "CharacterNames.h"
+#include "FloatQuad.h"
 #include "FrameView.h"
 #include "InlineTextBox.h"
 #include "Range.h"
@@ -302,13 +303,13 @@ InlineTextBox* RenderText::findNextInlineTextBox(int offset, int& pos) const
         return 0;
 
     InlineTextBox* s = m_firstTextBox;
-    int off = s->m_len;
+    int off = s->len();
     while (offset > off && s->nextTextBox()) {
         s = s->nextTextBox();
-        off = s->m_start + s->m_len;
+        off = s->start() + s->len();
     }
     // we are now in the correct text run
-    pos = (offset > off ? s->m_len : s->m_len - (off - offset) );
+    pos = (offset > off ? s->len() : s->len() - (off - offset) );
     return s;
 }
 
@@ -325,13 +326,13 @@ VisiblePosition RenderText::positionForCoordinates(int x, int y)
         // at the y coordinate of the first line or above
         // and the x coordinate is to the left of the first text box left edge
         offset = firstTextBox()->offsetForPosition(x);
-        return VisiblePosition(element(), offset + firstTextBox()->m_start, DOWNSTREAM);
+        return VisiblePosition(element(), offset + firstTextBox()->start(), DOWNSTREAM);
     }
     if (lastTextBox() && y >= lastTextBox()->root()->topOverflow() && x >= lastTextBox()->m_x + lastTextBox()->m_width) {
         // at the y coordinate of the last line or below
         // and the x coordinate is to the right of the last text box right edge
         offset = lastTextBox()->offsetForPosition(x);
-        return VisiblePosition(element(), offset + lastTextBox()->m_start, DOWNSTREAM);
+        return VisiblePosition(element(), offset + lastTextBox()->start(), DOWNSTREAM);
     }
 
     InlineTextBox* lastBoxAbove = 0;
@@ -344,29 +345,29 @@ VisiblePosition RenderText::positionForCoordinates(int x, int y)
                 if (x == box->m_x)
                     // the x coordinate is equal to the left edge of this box
                     // the affinity must be downstream so the position doesn't jump back to the previous line
-                    return VisiblePosition(element(), offset + box->m_start, DOWNSTREAM);
+                    return VisiblePosition(element(), offset + box->start(), DOWNSTREAM);
 
                 if (x < box->m_x + box->m_width)
                     // and the x coordinate is to the left of the right edge of this box
                     // check to see if position goes in this box
-                    return VisiblePosition(element(), offset + box->m_start, offset > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
+                    return VisiblePosition(element(), offset + box->start(), offset > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
 
                 if (!box->prevOnLine() && x < box->m_x)
                     // box is first on line
                     // and the x coordinate is to the left of the first text box left edge
-                    return VisiblePosition(element(), offset + box->m_start, DOWNSTREAM);
+                    return VisiblePosition(element(), offset + box->start(), DOWNSTREAM);
 
                 if (!box->nextOnLine())
                     // box is last on line
                     // and the x coordinate is to the right of the last text box right edge
                     // generate VisiblePosition, use UPSTREAM affinity if possible
-                    return VisiblePosition(element(), offset + box->m_start, offset > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
+                    return VisiblePosition(element(), offset + box->start(), offset > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
             }
             lastBoxAbove = box;
         }
     }
 
-    return VisiblePosition(element(), lastBoxAbove ? lastBoxAbove->m_start + lastBoxAbove->m_len : 0, DOWNSTREAM);
+    return VisiblePosition(element(), lastBoxAbove ? lastBoxAbove->start() + lastBoxAbove->len() : 0, DOWNSTREAM);
 }
 
 IntRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, int* extraWidthToEndOfLine)
@@ -857,7 +858,7 @@ static inline bool isInlineFlowOrEmptyText(RenderObject* o)
         return true;
     if (!o->isText())
         return false;
-    StringImpl* text = static_cast<RenderText*>(o)->text();
+    StringImpl* text = toRenderText(o)->text();
     if (!text)
         return true;
     return !text->length();
@@ -872,7 +873,7 @@ UChar RenderText::previousCharacter()
             break;
     UChar prev = ' ';
     if (previousText && previousText->isText())
-        if (StringImpl* previousString = static_cast<RenderText*>(previousText)->text())
+        if (StringImpl* previousString = toRenderText(previousText)->text())
             prev = (*previousString)[previousString->length() - 1];
     return prev;
 }
@@ -1003,7 +1004,7 @@ void RenderText::position(InlineBox* box)
     InlineTextBox* s = static_cast<InlineTextBox*>(box);
 
     // FIXME: should not be needed!!!
-    if (!s->m_len) {
+    if (!s->len()) {
         // We want the box to be destroyed.
         s->remove();
         s->destroy(renderArena());
@@ -1132,9 +1133,9 @@ int RenderText::caretMinOffset() const
     InlineTextBox* box = firstTextBox();
     if (!box)
         return 0;
-    int minOffset = box->m_start;
+    int minOffset = box->start();
     for (box = box->nextTextBox(); box; box = box->nextTextBox())
-        minOffset = min(minOffset, box->m_start);
+        minOffset = min<int>(minOffset, box->start());
     return minOffset;
 }
 
@@ -1143,9 +1144,9 @@ int RenderText::caretMaxOffset() const
     InlineTextBox* box = lastTextBox();
     if (!box)
         return textLength();
-    int maxOffset = box->m_start + box->m_len;
+    int maxOffset = box->start() + box->len();
     for (box = box->prevTextBox(); box; box = box->prevTextBox())
-        maxOffset = max(maxOffset, box->m_start + box->m_len);
+        maxOffset = max<int>(maxOffset, box->start() + box->len());
     return maxOffset;
 }
 
@@ -1153,7 +1154,7 @@ unsigned RenderText::caretMaxRenderedOffset() const
 {
     int l = 0;
     for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
-        l += box->m_len;
+        l += box->len();
     return l;
 }
 
index 5d88c40..7736f1a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * (C) 1999 Lars Knoll (knoll@kde.org)
  * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -169,6 +169,18 @@ private:
     bool m_isAllASCII : 1;
 };
 
+inline RenderText* toRenderText(RenderObject* o)
+{ 
+    ASSERT(!o || o->isText());
+    return static_cast<RenderText*>(o);
+}
+
+inline const RenderText* toRenderText(const RenderObject* o)
+{ 
+    ASSERT(!o || o->isText());
+    return static_cast<const RenderText*>(o);
+}
+
 #ifdef NDEBUG
 inline void RenderText::checkConsistency() const
 {
index 87c0c4d..fdbfaf2 100644 (file)
@@ -31,6 +31,7 @@
 #include "HTMLFormControlElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
+#include "RenderText.h"
 #include "ScrollbarTheme.h"
 #include "SelectionController.h"
 #include "TextControlInnerElements.h"
@@ -359,7 +360,7 @@ String RenderTextControl::textWithHardLineBreaks()
     if (!renderer)
         return "";
 
-    InlineBox* box = renderer->isText() ? static_cast<RenderText*>(renderer)->firstTextBox() : renderer->inlineBoxWrapper();
+    InlineBox* box = renderer->isText() ? toRenderText(renderer)->firstTextBox() : renderer->inlineBoxWrapper();
     if (!box)
         return "";
 
index 700b13e..e155609 100644 (file)
@@ -187,7 +187,7 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
     if (o.isText()) {
         // FIXME: Would be better to dump the bounding box x and y rather than the first run's x and y, but that would involve updating
         // many test results.
-        const RenderText& text = static_cast<const RenderText&>(o);
+        const RenderText& text = *toRenderText(&o);
         IntRect linesBox = text.linesBoundingBox();
         r = IntRect(text.firstRunX(), text.firstRunY(), linesBox.width(), linesBox.height());
         if (adjustForTableCells && !text.firstTextBox())
@@ -205,7 +205,7 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
             const RenderTableCell& cell = static_cast<const RenderTableCell&>(o);
             r = IntRect(cell.x(), cell.y() + cell.intrinsicPaddingTop(), cell.width(), cell.height() - cell.intrinsicPaddingTop() - cell.intrinsicPaddingBottom());
         } else
-            r = static_cast<const RenderBox&>(o).frameRect();
+            r = toRenderBox(&o)->frameRect();
     }
 
     // FIXME: Temporary in order to ensure compatibility with existing layout test results.
@@ -240,7 +240,7 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
         if (!o.isBox())
             return ts;
 
-        const RenderBox& box = static_cast<const RenderBox&>(o);
+        const RenderBox& box = *toRenderBox(&o);
         if (box.borderTop() || box.borderRight() || box.borderBottom() || box.borderLeft()) {
             ts << " [border:";
 
@@ -350,7 +350,7 @@ static void writeTextRun(TextStream& ts, const RenderText& o, const InlineTextBo
             ts << " override";
     }
     ts << ": "
-        << quoteAndEscapeNonPrintables(String(o.text()).substring(run.m_start, run.m_len))
+        << quoteAndEscapeNonPrintables(String(o.text()).substring(run.start(), run.len()))
         << "\n";
 }
 
@@ -383,7 +383,7 @@ void write(TextStream& ts, const RenderObject& o, int indent)
     ts << o << "\n";
 
     if (o.isText() && !o.isBR()) {
-        const RenderText& text = static_cast<const RenderText&>(o);
+        const RenderText& text = *toRenderText(&o);
         for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
             writeIndent(ts, indent + 1);
             writeTextRun(ts, text, *box);
index 5296caf..b3845c4 100644 (file)
@@ -1,8 +1,6 @@
-/**
- * This file is part of the HTML widget for KDE.
- *
+/*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -25,6 +23,7 @@
 
 #include "Document.h"
 #include "Element.h"
+#include "FloatQuad.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
index 199396f..53fad27 100644 (file)
@@ -278,7 +278,7 @@ inline void InlineIterator::increment(InlineBidiResolver* resolver)
         return;
     if (obj->isText()) {
         pos++;
-        if (pos >= static_cast<RenderText*>(obj)->textLength()) {
+        if (pos >= toRenderText(obj)->textLength()) {
             obj = bidiNext(block, obj, resolver);
             pos = 0;
             nextBreakablePosition = -1;
@@ -306,7 +306,7 @@ inline UChar InlineIterator::current() const
     if (!obj || !obj->isText())
         return 0;
 
-    RenderText* text = static_cast<RenderText*>(obj);
+    RenderText* text = toRenderText(obj);
     if (pos >= text->textLength())
         return 0;
 
@@ -358,12 +358,12 @@ static void checkMidpoints(InlineIterator& lBreak)
             if (endpoint.obj->style()->collapseWhiteSpace()) {
                 if (endpoint.obj->isText()) {
                     // Don't shave a character off the endpoint if it was from a soft hyphen.
-                    RenderText* textObj = static_cast<RenderText*>(endpoint.obj);
+                    RenderText* textObj = toRenderText(endpoint.obj);
                     if (endpoint.pos + 1 < textObj->textLength()) {
                         if (textObj->characters()[endpoint.pos+1] == softHyphen)
                             return;
                     } else if (startpoint.obj->isText()) {
-                        RenderText *startText = static_cast<RenderText*>(startpoint.obj);
+                        RenderText *startText = toRenderText(startpoint.obj);
                         if (startText->textLength() && startText->characters()[0] == softHyphen)
                             return;
                     }
@@ -578,7 +578,7 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, Bidi
                       // correct static x position.  They have no effect on the width.
                       // Similarly, line break boxes have no effect on the width.
         if (r->m_object->isText()) {
-            RenderText* rt = static_cast<RenderText*>(r->m_object);
+            RenderText* rt = toRenderText(r->m_object);
 
             if (textAlign == JUSTIFY && r != trailingSpaceRun) {
                 const UChar* characters = rt->characters();
@@ -688,7 +688,7 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, Bidi
             int spaceAdd = 0;
             if (r->m_object->isText() && !r->m_compact) {
                 unsigned spaces = 0;
-                const UChar* characters = static_cast<RenderText*>(r->m_object)->characters();
+                const UChar* characters = toRenderText(r->m_object)->characters();
                 for (int i = r->m_start; i < r->m_stop; i++) {
                     UChar c = characters[i];
                     if (c == ' ' || c == '\n' || c == '\t')
@@ -963,7 +963,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
                     trailingSpaceRun = resolver.logicallyLastRun();
                     RenderObject* lastObject = trailingSpaceRun->m_object;
                     if (lastObject->isText()) {
-                        RenderText* lastText = static_cast<RenderText*>(lastObject);
+                        RenderText* lastText = toRenderText(lastObject);
                         const UChar* characters = lastText->characters();
                         int firstSpace = trailingSpaceRun->stop();
                         while (firstSpace > trailingSpaceRun->start()) {
@@ -1211,7 +1211,7 @@ RootInlineBox* RenderBlock::determineStartPosition(bool& fullLayout, InlineBidiR
             // We have a dirty line.
             if (RootInlineBox* prevRootBox = curr->prevRootBox()) {
                 // We have a previous line.
-                if (!dirtiedByFloat && (!prevRootBox->endsWithBreak() || prevRootBox->lineBreakObj()->isText() && prevRootBox->lineBreakPos() >= static_cast<RenderText*>(prevRootBox->lineBreakObj())->textLength()))
+                if (!dirtiedByFloat && (!prevRootBox->endsWithBreak() || prevRootBox->lineBreakObj()->isText() && prevRootBox->lineBreakPos() >= toRenderText(prevRootBox->lineBreakObj())->textLength()))
                     // The previous line didn't break cleanly or broke at a newline
                     // that has been deleted, so treat it as dirty too.
                     curr = prevRootBox;
@@ -1531,8 +1531,8 @@ int RenderBlock::skipLeadingWhitespace(InlineBidiResolver& resolver)
 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObject* o)
 {
     RenderObject* next = bidiNext(block, o);
-    if (next && !next->isBR() && next->isText() && static_cast<RenderText*>(next)->textLength() > 0) {
-        RenderText* nextText = static_cast<RenderText*>(next);
+    if (next && !next->isBR() && next->isText() && toRenderText(next)->textLength() > 0) {
+        RenderText* nextText = toRenderText(next);
         UChar nextChar = nextText->characters()[0];
         if (nextText->style()->isCollapsibleWhiteSpace(nextChar)) {
             addMidpoint(InlineIterator(0, o, 0));
@@ -1768,7 +1768,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, ECle
             if (!pos)
                 appliedStartWidth = false;
 
-            RenderText* t = static_cast<RenderText*>(o);
+            RenderText* t = toRenderText(o);
 
             int strlen = t->textLength();
             int len = strlen - pos;
@@ -1815,7 +1815,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, ECle
                         if (pos)
                             beforeSoftHyphen = InlineIterator(0, o, pos - 1);
                         else
-                            beforeSoftHyphen = InlineIterator(0, last, last->isText() ? static_cast<RenderText*>(last)->textLength() - 1 : 0);
+                            beforeSoftHyphen = InlineIterator(0, last, last->isText() ? toRenderText(last)->textLength() - 1 : 0);
                         // Two consecutive soft hyphens. Avoid overlapping midpoints.
                         if (sNumMidpoints && smidpoints->at(sNumMidpoints - 1).obj == o && smidpoints->at(sNumMidpoints - 1).pos == pos)
                             sNumMidpoints--;
@@ -1905,7 +1905,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, ECle
                             }
                         }
                         if (lineWasTooWide || w + tmpW > width) {
-                            if (lBreak.obj && shouldPreserveNewline(lBreak.obj) && lBreak.obj->isText() && !static_cast<RenderText*>(lBreak.obj)->isWordBreak() && static_cast<RenderText*>(lBreak.obj)->characters()[lBreak.pos] == '\n') {
+                            if (lBreak.obj && shouldPreserveNewline(lBreak.obj) && lBreak.obj->isText() && !toRenderText(lBreak.obj)->isWordBreak() && toRenderText(lBreak.obj)->characters()[lBreak.pos] == '\n') {
                                 if (!stoppedIgnoringSpaces && pos > 0) {
                                     // We need to stop right before the newline and then start up again.
                                     addMidpoint(InlineIterator(0, o, pos - 1)); // Stop
@@ -2026,7 +2026,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, ECle
                     checkForBreak = true;
                 else {
                     checkForBreak = false;
-                    RenderText* nextText = static_cast<RenderText*>(next);
+                    RenderText* nextText = toRenderText(next);
                     if (nextText->textLength()) {
                         UChar c = nextText->characters()[0];
                         if (c == ' ' || c == '\t' || (c == '\n' && !shouldPreserveNewline(next)))
@@ -2150,7 +2150,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, ECle
         //    lBreak.pos--;
         else if (lBreak.obj == 0 && trailingSpaceObject->isText()) {
             // Add a new end midpoint that stops right at the very end.
-            RenderText* text = static_cast<RenderText *>(trailingSpaceObject);
+            RenderText* text = toRenderText(trailingSpaceObject);
             unsigned length = text->textLength();
             unsigned pos = length >= 2 ? length - 2 : UINT_MAX;
             InlineIterator endMid(0, trailingSpaceObject, pos);
@@ -2170,7 +2170,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, ECle
     if (lBreak.obj && lBreak.pos >= 2 && lBreak.obj->isText()) {
         // For soft hyphens on line breaks, we have to chop out the midpoints that made us
         // ignore the hyphen so that it will render at the end of the line.
-        UChar c = static_cast<RenderText*>(lBreak.obj)->characters()[lBreak.pos-1];
+        UChar c = toRenderText(lBreak.obj)->characters()[lBreak.pos-1];
         if (c == softHyphen)
             chopMidpointsAt(lBreak.obj, lBreak.pos-2);
     }
index 1a3f8cf..5473f55 100644 (file)
@@ -1,3 +1,15 @@
+2009-01-25  Darin Adler  <darin@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Bug 23522: use checked casts for render tree
+        https://bugs.webkit.org/show_bug.cgi?id=23522
+
+        Step one: RenderText.
+
+        * WebView/WebRenderNode.mm:
+        (copyRenderNode): Use toRenderText.
+
 2009-01-23  Brady Eidson  <beidson@apple.com>
 
         Rubberstamped by Darin Adler
index 183013b..65ee13c 100644 (file)
@@ -94,14 +94,14 @@ static WebRenderNode *copyRenderNode(RenderObject* node)
     int width = 0;
     int height = 0;
     if (node->isBox()) {
-        RenderBox* box = static_cast<RenderBox*>(node);
+        RenderBox* box = toRenderBox(node);
         x = box->x();
         y = box->y();
         width = box->width();
         height = box->height();
     } else if (node->isText()) {
         // FIXME: Preserve old behavior even though it's strange.
-        RenderText* text = static_cast<RenderText*>(node);
+        RenderText* text = toRenderText(node);
         x = text->firstRunX();
         y = text->firstRunY();
         IntRect box = text->linesBoundingBox();