Commit 36744d67 authored by darin@apple.com's avatar darin@apple.com

WebCore:

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: http://svn.webkit.org/repository/webkit/trunk@40229 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5c0d6af8
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.
......@@ -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());
......
......@@ -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"
......@@ -34,11 +32,9 @@
#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 {
......
/*
* 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
......@@ -29,14 +29,12 @@
#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();
RenderObject* renderer = 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 (InlineTextBox* box = 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;
......
......@@ -26,16 +26,12 @@
#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");
......
......@@ -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();
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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)
......
/*
* 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"
......
/*
* 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();
}