[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
hyatt
hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:03:38 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 5271ab1eab08edfcdb37cdd35d32abcca752937a
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 20 07:07:54 2003 +0000
Make first-letter and before/after work with text transforms.
Reviewed by mjs
* khtml/rendering/render_block.cpp:
(khtml::RenderBlock::addChildToFlow):
* khtml/rendering/render_container.cpp:
(RenderContainer::updatePseudoChild):
* khtml/rendering/render_text.cpp:
(RenderText::setStyle):
(RenderText::isTextFragment):
(RenderText::originalString):
(RenderText::setText):
(m_generatedContentStr):
(m_start):
(RenderTextFragment::~RenderTextFragment):
(RenderTextFragment::isTextFragment):
(RenderTextFragment::originalString):
* khtml/rendering/render_text.h:
(khtml::RenderTextFragment::start):
(khtml::RenderTextFragment::end):
(khtml::RenderTextFragment::contentString):
* khtml/xml/dom_nodeimpl.h:
(DOM::NodeImpl::setRenderer):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5222 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 5949c03..641b05d 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,30 @@
+2003-10-20 David Hyatt <hyatt at apple.com>
+
+ Make first-letter and before/after work with text transforms.
+
+ Reviewed by mjs
+
+ * khtml/rendering/render_block.cpp:
+ (khtml::RenderBlock::addChildToFlow):
+ * khtml/rendering/render_container.cpp:
+ (RenderContainer::updatePseudoChild):
+ * khtml/rendering/render_text.cpp:
+ (RenderText::setStyle):
+ (RenderText::isTextFragment):
+ (RenderText::originalString):
+ (RenderText::setText):
+ (m_generatedContentStr):
+ (m_start):
+ (RenderTextFragment::~RenderTextFragment):
+ (RenderTextFragment::isTextFragment):
+ (RenderTextFragment::originalString):
+ * khtml/rendering/render_text.h:
+ (khtml::RenderTextFragment::start):
+ (khtml::RenderTextFragment::end):
+ (khtml::RenderTextFragment::contentString):
+ * khtml/xml/dom_nodeimpl.h:
+ (DOM::NodeImpl::setRenderer):
+
2003-10-19 David Hyatt <hyatt at apple.com>
Remove the "flow-around-floats" hack for lists. Other browsers don't do this.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5949c03..641b05d 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,30 @@
+2003-10-20 David Hyatt <hyatt at apple.com>
+
+ Make first-letter and before/after work with text transforms.
+
+ Reviewed by mjs
+
+ * khtml/rendering/render_block.cpp:
+ (khtml::RenderBlock::addChildToFlow):
+ * khtml/rendering/render_container.cpp:
+ (RenderContainer::updatePseudoChild):
+ * khtml/rendering/render_text.cpp:
+ (RenderText::setStyle):
+ (RenderText::isTextFragment):
+ (RenderText::originalString):
+ (RenderText::setText):
+ (m_generatedContentStr):
+ (m_start):
+ (RenderTextFragment::~RenderTextFragment):
+ (RenderTextFragment::isTextFragment):
+ (RenderTextFragment::originalString):
+ * khtml/rendering/render_text.h:
+ (khtml::RenderTextFragment::start):
+ (khtml::RenderTextFragment::end):
+ (khtml::RenderTextFragment::contentString):
+ * khtml/xml/dom_nodeimpl.h:
+ (DOM::NodeImpl::setRenderer):
+
2003-10-19 David Hyatt <hyatt at apple.com>
Remove the "flow-around-floats" hack for lists. Other browsers don't do this.
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index 710dbfb..3132596 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -116,7 +116,7 @@ void RenderBlock::addChildToFlow(RenderObject* newChild, RenderObject* beforeChi
if (!firstLetterContainer)
firstLetterContainer = this;
- RenderText* newTextChild = static_cast<RenderText*>(textChild);
+ RenderText* textObj = static_cast<RenderText*>(textChild);
//kdDebug( 6040 ) << "first letter" << endl;
// Force inline display (except for floating first-letters)
@@ -126,24 +126,41 @@ void RenderBlock::addChildToFlow(RenderObject* newChild, RenderObject* beforeChi
RenderObject* firstLetter = RenderFlow::createAnonymousFlow(document(), pseudoStyle); // anonymous box
firstLetterContainer->addChild(firstLetter, firstLetterContainer->firstChild());
- DOMStringImpl* oldText = newTextChild->string();
+ // The original string is going to be either a generated content string or a DOM node's
+ // string. We want the original string before it got transformed in case first-letter has
+ // no text-transform or a different text-transform applied to it.
+ DOMStringImpl* oldText = textObj->originalString();
- if(oldText->l >= 1) {
+ if (oldText->l >= 1) {
unsigned int length = 0;
while ( length < oldText->l &&
( (oldText->s+length)->isSpace() || (oldText->s+length)->isPunct() ) )
length++;
length++;
//kdDebug( 6040 ) << "letter= '" << DOMString(oldText->substring(0,length)).string() << "'" << endl;
- newTextChild->setText(oldText->substring(length,oldText->l-length));
-
- RenderText* letter = new (renderArena()) RenderText(newTextChild->node(), oldText->substring(0,length));
+
+ RenderTextFragment* remainingText =
+ new (renderArena()) RenderTextFragment(textObj->node(), oldText, length, oldText->l-length);
+ remainingText->setStyle(textObj->style());
+ if (remainingText->element())
+ remainingText->element()->setRenderer(remainingText);
+ if (textObj->parent()) {
+ RenderObject* nextObj = textObj->nextSibling();
+ firstLetterContainer->removeChild(textObj);
+ firstLetterContainer->addChild(remainingText, nextObj);
+ }
+ else {
+ newChild->detach();
+ newChild = remainingText;
+ }
+
+ RenderTextFragment* letter =
+ new (renderArena()) RenderTextFragment(remainingText->node(), oldText, 0, length);
RenderStyle* newStyle = new RenderStyle();
newStyle->inheritFrom(pseudoStyle);
letter->setStyle(newStyle);
firstLetter->addChild(letter);
}
- firstLetter->close();
}
}
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index 9470936..672c09b 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -308,10 +308,9 @@ void RenderContainer::updatePseudoChild(RenderStyle::PseudoId type, RenderObject
if (contentData->contentType() == CONTENT_TEXT)
{
- RenderText* t = new (renderArena()) RenderText(document() /*anonymous object */, contentData->contentText());
+ RenderText* t = new (renderArena()) RenderTextFragment(document() /*anonymous object */, contentData->contentText());
t->setStyle(pseudo);
pseudoContainer->addChild(t);
- t->close();
}
else if (contentData->contentType() == CONTENT_OBJECT)
{
@@ -321,7 +320,6 @@ void RenderContainer::updatePseudoChild(RenderStyle::PseudoId type, RenderObject
img->setStyle(style);
img->setContentObject(contentData->contentObject());
pseudoContainer->addChild(img);
- img->close();
}
}
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 7ec99c1..b922a9b 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -306,18 +306,19 @@ RenderText::RenderText(DOM::NodeImpl* node, DOMStringImpl *_str)
void RenderText::setStyle(RenderStyle *_style)
{
if ( style() != _style ) {
- // ### fontvariant being implemented as text-transform: upper. sucks!
- bool changedText = (!style() && (_style->fontVariant() != FVNORMAL || _style->textTransform() != TTNONE)) ||
- ((style() && style()->textTransform() != _style->textTransform()) ||
- (style() && style()->fontVariant() != _style->fontVariant()));
+ bool needToTransformText = (!style() && _style->textTransform() != TTNONE) ||
+ (style() && style()->textTransform() != _style->textTransform());
RenderObject::setStyle( _style );
m_lineHeight = RenderObject::lineHeight(false);
- if (changedText && element() && element()->string())
- setText(element()->string(), changedText);
+ if (needToTransformText) {
+ DOM::DOMStringImpl* textToTransform = originalString();
+ if (textToTransform)
+ setText(textToTransform, true);
+ }
#if APPLE_CHANGES
- // set also call cacheWidths(), so no need to recache if that has already been done.
+ // setText also calls cacheWidths(), so there is no need to call it again in that case.
else
cacheWidths();
#endif
@@ -355,6 +356,16 @@ void RenderText::deleteRuns()
KHTMLAssert(m_lines.count() == 0);
}
+bool RenderText::isTextFragment() const
+{
+ return false;
+}
+
+DOM::DOMStringImpl* RenderText::originalString() const
+{
+ return element() ? element()->string() : 0;
+}
+
InlineTextBox * RenderText::findNextInlineTextBox( int offset, int &pos )
{
// The text runs point to parts of the rendertext's str string
@@ -1167,16 +1178,13 @@ void RenderText::setText(DOMStringImpl *text, bool force)
if (str) {
str = str->replace('\\', backslashAsCurrencySymbol());
if ( style() ) {
- if ( style()->fontVariant() == SMALL_CAPS )
- str = str->upper();
- else
- switch(style()->textTransform()) {
+ switch(style()->textTransform()) {
case CAPITALIZE: str = str->capitalize(); break;
case UPPERCASE: str = str->upper(); break;
case LOWERCASE: str = str->lower(); break;
case NONE:
default:;
- }
+ }
}
str->ref();
}
@@ -1420,5 +1428,45 @@ void RenderText::paintTextOutline(QPainter *p, int tx, int ty, const QRect &last
true);
}
+RenderTextFragment::RenderTextFragment(DOM::NodeImpl* _node, DOM::DOMStringImpl* _str,
+ int startOffset, int endOffset)
+:RenderText(_node, _str->substring(startOffset, endOffset)),
+m_start(startOffset), m_end(endOffset), m_generatedContentStr(0)
+{}
+
+RenderTextFragment::RenderTextFragment(DOM::NodeImpl* _node, DOM::DOMStringImpl* _str)
+:RenderText(_node, _str), m_start(0)
+{
+ m_generatedContentStr = _str;
+ if (_str) {
+ _str->ref();
+ m_end = _str->l;
+ }
+ else
+ m_end = 0;
+}
+
+RenderTextFragment::~RenderTextFragment()
+{
+ if (m_generatedContentStr)
+ m_generatedContentStr->deref();
+}
+
+bool RenderTextFragment::isTextFragment() const
+{
+ return true;
+}
+
+DOM::DOMStringImpl* RenderTextFragment::originalString() const
+{
+ DOM::DOMStringImpl* result = 0;
+ if (element())
+ result = element()->string();
+ else
+ result = contentString();
+ if (result && (start() > 0 || start() < result->l))
+ result = result->substring(start(), end());
+ return result;
+}
#undef BIDI_DEBUG
#undef DEBUG_LAYOUT
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index d082616..455e1c2 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -122,10 +122,13 @@ public:
RenderText(DOM::NodeImpl* node, DOM::DOMStringImpl *_str);
virtual ~RenderText();
+ virtual bool isTextFragment() const;
+ virtual DOM::DOMStringImpl* originalString() const;
+
virtual const char *renderName() const { return "RenderText"; }
virtual void setStyle(RenderStyle *style);
-
+
virtual void paint(QPainter *, int x, int y, int w, int h,
int tx, int ty, PaintAction paintAction);
virtual void paintObject(QPainter *, int x, int y, int w, int h,
@@ -247,6 +250,30 @@ protected: // members
#endif
};
-
+// Used to represent a text substring of an element, e.g., for text runs that are split because of
+// first letter and that must therefore have different styles (and positions in the render tree).
+// We cache offsets so that text transformations can be applied in such a way that we can recover
+// the original unaltered string from our corresponding DOM node.
+class RenderTextFragment : public RenderText
+{
+public:
+ RenderTextFragment(DOM::NodeImpl* _node, DOM::DOMStringImpl* _str,
+ int startOffset, int endOffset);
+ RenderTextFragment(DOM::NodeImpl* _node, DOM::DOMStringImpl* _str);
+ ~RenderTextFragment();
+
+ virtual bool isTextFragment() const;
+
+ uint start() const { return m_start; }
+ uint end() const { return m_end; }
+
+ DOM::DOMStringImpl* contentString() const { return m_generatedContentStr; }
+ virtual DOM::DOMStringImpl* originalString() const;
+
+private:
+ uint m_start;
+ uint m_end;
+ DOM::DOMStringImpl* m_generatedContentStr;
+};
};
#endif
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index 4822a46..29e22f1 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -280,7 +280,8 @@ public:
khtml::RenderObject *renderer() const { return m_render; }
khtml::RenderObject *nextRenderer();
khtml::RenderObject *previousRenderer();
-
+ void setRenderer(khtml::RenderObject* renderer) { m_render = renderer; }
+
void checkSetPrefix(const DOMString &_prefix, int &exceptioncode);
void checkAddChild(NodeImpl *newChild, int &exceptioncode);
bool isAncestor( NodeImpl *other );
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list