[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
hyatt at apple.com
hyatt at apple.com
Fri Feb 26 22:17:55 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit d1a2553eec111a4f4e6a7551efcd12efc762d652
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 11 20:05:51 2010 +0000
https://bugs.webkit.org/show_bug.cgi?id=34857
Move InlineIterator and BidiRun into new files so subclasses can access them.
Reviewed by Dan Bernstein.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* rendering/BidiRun.cpp: Added.
(WebCore::BidiRun::destroy):
(WebCore::throw):
(WebCore::BidiRun::operator delete):
* rendering/BidiRun.h: Added.
(WebCore::BidiRun::BidiRun):
(WebCore::BidiRun::next):
* rendering/InlineIterator.h: Added.
(WebCore::InlineIterator::InlineIterator):
(WebCore::operator==):
(WebCore::operator!=):
(WebCore::bidiNext):
(WebCore::bidiFirst):
(WebCore::InlineIterator::increment):
(WebCore::InlineIterator::atEnd):
(WebCore::InlineIterator::current):
(WebCore::InlineIterator::direction):
(WebCore::InlineBidiResolver::increment):
(WebCore::InlineBidiResolver::appendRun):
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::appendRunsForObject):
(WebCore::RenderBlock::requiresLineBox):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1ddf9d5..f35f44e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,39 @@
+2010-02-11 David Hyatt <hyatt at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ https://bugs.webkit.org/show_bug.cgi?id=34857
+ Move InlineIterator and BidiRun into new files so subclasses can access them.
+
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/BidiRun.cpp: Added.
+ (WebCore::BidiRun::destroy):
+ (WebCore::throw):
+ (WebCore::BidiRun::operator delete):
+ * rendering/BidiRun.h: Added.
+ (WebCore::BidiRun::BidiRun):
+ (WebCore::BidiRun::next):
+ * rendering/InlineIterator.h: Added.
+ (WebCore::InlineIterator::InlineIterator):
+ (WebCore::operator==):
+ (WebCore::operator!=):
+ (WebCore::bidiNext):
+ (WebCore::bidiFirst):
+ (WebCore::InlineIterator::increment):
+ (WebCore::InlineIterator::atEnd):
+ (WebCore::InlineIterator::current):
+ (WebCore::InlineIterator::direction):
+ (WebCore::InlineBidiResolver::increment):
+ (WebCore::InlineBidiResolver::appendRun):
+ * rendering/RenderBlock.h:
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlock::appendRunsForObject):
+ (WebCore::RenderBlock::requiresLineBox):
+
2010-02-11 Steve Block <steveblock at google.com>
Reviewed by Dimitri Glazkov.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index ca7b8f6..e0c9dc6 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1736,6 +1736,8 @@ webcore_sources += \
WebCore/plugins/npfunctions.h \
WebCore/rendering/AutoTableLayout.cpp \
WebCore/rendering/AutoTableLayout.h \
+ WebCore/rendering/BidiRun.cpp \
+ WebCore/rendering/BidiRun.h \
WebCore/rendering/CounterNode.cpp \
WebCore/rendering/CounterNode.h \
WebCore/rendering/EllipsisBox.cpp \
@@ -1750,6 +1752,7 @@ webcore_sources += \
WebCore/rendering/InlineBox.h \
WebCore/rendering/InlineFlowBox.cpp \
WebCore/rendering/InlineFlowBox.h \
+ WebCore/rendering/InlineIterator.h \
WebCore/rendering/InlineRunBox.h \
WebCore/rendering/InlineTextBox.cpp \
WebCore/rendering/InlineTextBox.h \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index ca9fd10..22b6117 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2967,6 +2967,8 @@
'rendering/style/StyleVisualData.h',
'rendering/AutoTableLayout.cpp',
'rendering/AutoTableLayout.h',
+ 'rendering/BidiRun.cpp',
+ 'rendering/BidiRun.h',
'rendering/CounterNode.cpp',
'rendering/CounterNode.h',
'rendering/EllipsisBox.cpp',
@@ -2981,6 +2983,7 @@
'rendering/InlineBox.h',
'rendering/InlineFlowBox.cpp',
'rendering/InlineFlowBox.h',
+ 'rendering/InlineIterator.h',
'rendering/InlineRunBox.h',
'rendering/InlineTextBox.cpp',
'rendering/InlineTextBox.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index c49236f..976f795 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -865,6 +865,7 @@ SOURCES += \
plugins/PluginView.cpp \
rendering/AutoTableLayout.cpp \
rendering/break_lines.cpp \
+ rendering/BidiRun.cpp \
rendering/CounterNode.cpp \
rendering/EllipsisBox.cpp \
rendering/FixedTableLayout.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 21df2bc..ff7963b 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -27044,6 +27044,14 @@
RelativePath="..\rendering\break_lines.h"
>
</File>
+ <File
+ RelativePath="..\rendering\BidiRun.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\rendering\BidiRun.h"
+ >
+ </File>
<File
RelativePath="..\rendering\CounterNode.cpp"
>
@@ -27100,6 +27108,10 @@
RelativePath="..\rendering\InlineFlowBox.h"
>
</File>
+ <File
+ RelativePath="..\rendering\InlineIterator.h"
+ >
+ </File>
<File
RelativePath="..\rendering\InlineRunBox.h"
>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index fcb14e7..e87206d 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4551,6 +4551,9 @@
BCE65BEA0EACDF16007E4533 /* Length.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE65BE80EACDF16007E4533 /* Length.cpp */; };
BCE65BEB0EACDF16007E4533 /* Length.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE65BE90EACDF16007E4533 /* Length.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCE65D320EAD1211007E4533 /* Theme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE65D310EAD1211007E4533 /* Theme.cpp */; };
+ BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE789151120D6080060ECE5 /* InlineIterator.h */; };
+ BCE789861120E7A60060ECE5 /* BidiRun.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE789851120E7A60060ECE5 /* BidiRun.h */; };
+ BCE7898B1120E8020060ECE5 /* BidiRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE7898A1120E8020060ECE5 /* BidiRun.cpp */; };
BCE7B1930D4E86960075A539 /* JSHistoryCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */; };
BCE99EC30DCA624100182683 /* JSXSLTProcessorConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE99EC10DCA624100182683 /* JSXSLTProcessorConstructor.cpp */; };
BCE99EC40DCA624100182683 /* JSXSLTProcessorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE99EC20DCA624100182683 /* JSXSLTProcessorConstructor.h */; };
@@ -9816,6 +9819,9 @@
BCE65BE80EACDF16007E4533 /* Length.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Length.cpp; sourceTree = "<group>"; };
BCE65BE90EACDF16007E4533 /* Length.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Length.h; sourceTree = "<group>"; };
BCE65D310EAD1211007E4533 /* Theme.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Theme.cpp; sourceTree = "<group>"; };
+ BCE789151120D6080060ECE5 /* InlineIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineIterator.h; sourceTree = "<group>"; };
+ BCE789851120E7A60060ECE5 /* BidiRun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BidiRun.h; sourceTree = "<group>"; };
+ BCE7898A1120E8020060ECE5 /* BidiRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BidiRun.cpp; sourceTree = "<group>"; };
BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHistoryCustom.cpp; sourceTree = "<group>"; };
BCE99EC10DCA624100182683 /* JSXSLTProcessorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXSLTProcessorConstructor.cpp; sourceTree = "<group>"; };
BCE99EC20DCA624100182683 /* JSXSLTProcessorConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXSLTProcessorConstructor.h; sourceTree = "<group>"; };
@@ -15565,6 +15571,8 @@
BC8C8FAA0DDCD2F200B592F4 /* style */,
A8CFF04B0A154F09000A4234 /* AutoTableLayout.cpp */,
A8CFF0490A154F09000A4234 /* AutoTableLayout.h */,
+ BCE7898A1120E8020060ECE5 /* BidiRun.cpp */,
+ BCE789851120E7A60060ECE5 /* BidiRun.h */,
BCEA4815097D93020094C9E4 /* break_lines.cpp */,
BCEA4816097D93020094C9E4 /* break_lines.h */,
9392F14F0AD1862300691BD4 /* CounterNode.cpp */,
@@ -15581,6 +15589,7 @@
A8CFF5DE0A155A05000A4234 /* InlineBox.h */,
A8CFF5DD0A155A05000A4234 /* InlineFlowBox.cpp */,
A8CFF5DC0A155A05000A4234 /* InlineFlowBox.h */,
+ BCE789151120D6080060ECE5 /* InlineIterator.h */,
A8CFF5DB0A155A05000A4234 /* InlineRunBox.h */,
BCEA481A097D93020094C9E4 /* InlineTextBox.cpp */,
BCEA481B097D93020094C9E4 /* InlineTextBox.h */,
@@ -18514,6 +18523,8 @@
B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
9F72304F11184B4100AD0126 /* ScriptProfile.h in Headers */,
9F72305111184B4100AD0126 /* ScriptProfiler.h in Headers */,
+ BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
+ BCE789861120E7A60060ECE5 /* BidiRun.h in Headers */,
9F6FC1971122E82A00E80196 /* ScriptDebugServer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -20693,6 +20704,7 @@
84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */,
B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */,
9F72305011184B4100AD0126 /* ScriptProfiler.cpp in Sources */,
+ BCE7898B1120E8020060ECE5 /* BidiRun.cpp in Sources */,
9F6FC1961122E82A00E80196 /* ScriptDebugServer.cpp in Sources */,
76FF17E311235673001D61B5 /* PluginViewNone.cpp in Sources */,
);
diff --git a/WebCore/rendering/BidiRun.cpp b/WebCore/rendering/BidiRun.cpp
new file mode 100644
index 0000000..ac13046
--- /dev/null
+++ b/WebCore/rendering/BidiRun.cpp
@@ -0,0 +1,74 @@
+/**
+ * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
+ * (C) 1999 Antti Koivisto (koivisto at kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Andrew Wellington (proton at wiretapped.net)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "BidiRun.h"
+#include "InlineBox.h"
+#include "RenderArena.h"
+#include <wtf/RefCountedLeakCounter.h>
+
+using namespace WTF;
+
+namespace WebCore {
+
+#ifndef NDEBUG
+static RefCountedLeakCounter bidiRunCounter("BidiRun");
+
+static bool inBidiRunDestroy;
+#endif
+
+void BidiRun::destroy()
+{
+#ifndef NDEBUG
+ inBidiRunDestroy = true;
+#endif
+ RenderArena* renderArena = m_object->renderArena();
+ delete this;
+#ifndef NDEBUG
+ inBidiRunDestroy = false;
+#endif
+
+ // Recover the size left there for us by operator delete and free the memory.
+ renderArena->free(*reinterpret_cast<size_t*>(this), this);
+}
+
+void* BidiRun::operator new(size_t sz, RenderArena* renderArena) throw()
+{
+#ifndef NDEBUG
+ bidiRunCounter.increment();
+#endif
+ return renderArena->allocate(sz);
+}
+
+void BidiRun::operator delete(void* ptr, size_t sz)
+{
+#ifndef NDEBUG
+ bidiRunCounter.decrement();
+#endif
+ ASSERT(inBidiRunDestroy);
+
+ // Stash size where destroy() can find it.
+ *(size_t*)ptr = sz;
+}
+
+}
diff --git a/WebCore/rendering/BidiRun.h b/WebCore/rendering/BidiRun.h
new file mode 100644
index 0000000..542081a
--- /dev/null
+++ b/WebCore/rendering/BidiRun.h
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
+ * (C) 1999 Antti Koivisto (koivisto at kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Andrew Wellington (proton at wiretapped.net)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef BidiRun_h
+#define BidiRun_h
+
+#include <wtf/StdLibExtras.h>
+#include "BidiResolver.h"
+#include "RenderText.h"
+
+namespace WebCore {
+
+class BidiContext;
+class InlineBox;
+
+struct BidiRun : BidiCharacterRun {
+ BidiRun(int start, int stop, RenderObject* object, BidiContext* context, WTF::Unicode::Direction dir)
+ : BidiCharacterRun(start, stop, context, dir)
+ , m_object(object)
+ , m_box(0)
+ {
+ }
+
+ void destroy();
+
+ // Overloaded new operator.
+ void* operator new(size_t, RenderArena*) throw();
+
+ // Overridden to prevent the normal delete from being called.
+ void operator delete(void*, size_t);
+
+ BidiRun* next() { return static_cast<BidiRun*>(m_next); }
+
+private:
+ // The normal operator new is disallowed.
+ void* operator new(size_t) throw();
+
+public:
+ RenderObject* m_object;
+ InlineBox* m_box;
+};
+
+}
+
+#endif // BidiRun_h
diff --git a/WebCore/rendering/InlineIterator.h b/WebCore/rendering/InlineIterator.h
new file mode 100644
index 0000000..9310ea8
--- /dev/null
+++ b/WebCore/rendering/InlineIterator.h
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll at kde.org)
+ * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All right reserved.
+ * Copyright (C) 2010 Google 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef InlineIterator_h
+#define InlineIterator_h
+
+#include "BidiRun.h"
+#include "RenderBlock.h"
+#include "RenderText.h"
+#include <wtf/AlwaysInline.h>
+#include <wtf/StdLibExtras.h>
+
+namespace WebCore {
+
+class InlineIterator {
+public:
+ InlineIterator()
+ : block(0)
+ , obj(0)
+ , pos(0)
+ , nextBreakablePosition(-1)
+ {
+ }
+
+ InlineIterator(RenderBlock* b, RenderObject* o, unsigned p)
+ : block(b)
+ , obj(o)
+ , pos(p)
+ , nextBreakablePosition(-1)
+ {
+ }
+
+ void increment(InlineBidiResolver* resolver = 0);
+ bool atEnd() const;
+
+ UChar current() const;
+ WTF::Unicode::Direction direction() const;
+
+ RenderBlock* block;
+ RenderObject* obj;
+ unsigned pos;
+ int nextBreakablePosition;
+};
+
+inline bool operator==(const InlineIterator& it1, const InlineIterator& it2)
+{
+ return it1.pos == it2.pos && it1.obj == it2.obj;
+}
+
+inline bool operator!=(const InlineIterator& it1, const InlineIterator& it2)
+{
+ return it1.pos != it2.pos || it1.obj != it2.obj;
+}
+
+static inline RenderObject* bidiNext(RenderBlock* block, RenderObject* current, InlineBidiResolver* resolver = 0, bool skipInlines = true, bool* endOfInlinePtr = 0)
+{
+ RenderObject* next = 0;
+ bool oldEndOfInline = endOfInlinePtr ? *endOfInlinePtr : false;
+ bool endOfInline = false;
+
+ while (current) {
+ next = 0;
+ if (!oldEndOfInline && !current->isFloating() && !current->isReplaced() && !current->isPositioned() && !current->isText()) {
+ next = current->firstChild();
+ if (next && resolver && next->isRenderInline()) {
+ EUnicodeBidi ub = next->style()->unicodeBidi();
+ if (ub != UBNormal) {
+ TextDirection dir = next->style()->direction();
+ WTF::Unicode::Direction d = (ub == Embed
+ ? (dir == RTL ? WTF::Unicode::RightToLeftEmbedding : WTF::Unicode::LeftToRightEmbedding)
+ : (dir == RTL ? WTF::Unicode::RightToLeftOverride : WTF::Unicode::LeftToRightOverride));
+ resolver->embed(d);
+ }
+ }
+ }
+
+ if (!next) {
+ if (!skipInlines && !oldEndOfInline && current->isRenderInline()) {
+ next = current;
+ endOfInline = true;
+ break;
+ }
+
+ while (current && current != block) {
+ if (resolver && current->isRenderInline() && current->style()->unicodeBidi() != UBNormal)
+ resolver->embed(WTF::Unicode::PopDirectionalFormat);
+
+ next = current->nextSibling();
+ if (next) {
+ if (resolver && next->isRenderInline()) {
+ EUnicodeBidi ub = next->style()->unicodeBidi();
+ if (ub != UBNormal) {
+ TextDirection dir = next->style()->direction();
+ WTF::Unicode::Direction d = (ub == Embed
+ ? (dir == RTL ? WTF::Unicode::RightToLeftEmbedding: WTF::Unicode::LeftToRightEmbedding)
+ : (dir == RTL ? WTF::Unicode::RightToLeftOverride : WTF::Unicode::LeftToRightOverride));
+ resolver->embed(d);
+ }
+ }
+ break;
+ }
+
+ current = current->parent();
+ if (!skipInlines && current && current != block && current->isRenderInline()) {
+ next = current;
+ endOfInline = true;
+ break;
+ }
+ }
+ }
+
+ if (!next)
+ break;
+
+ if (next->isText() || next->isFloating() || next->isReplaced() || next->isPositioned()
+ || ((!skipInlines || !next->firstChild()) // Always return EMPTY inlines.
+ && next->isRenderInline()))
+ break;
+ current = next;
+ }
+
+ if (endOfInlinePtr)
+ *endOfInlinePtr = endOfInline;
+
+ return next;
+}
+
+static inline RenderObject* bidiFirst(RenderBlock* block, InlineBidiResolver* resolver, bool skipInlines = true)
+{
+ if (!block->firstChild())
+ return 0;
+
+ RenderObject* o = block->firstChild();
+ if (o->isRenderInline()) {
+ if (resolver) {
+ EUnicodeBidi ub = o->style()->unicodeBidi();
+ if (ub != UBNormal) {
+ TextDirection dir = o->style()->direction();
+ WTF::Unicode::Direction d = (ub == Embed
+ ? (dir == RTL ? WTF::Unicode::RightToLeftEmbedding : WTF::Unicode::LeftToRightEmbedding)
+ : (dir == RTL ? WTF::Unicode::RightToLeftOverride : WTF::Unicode::LeftToRightOverride));
+ resolver->embed(d);
+ }
+ }
+ if (skipInlines && o->firstChild())
+ o = bidiNext(block, o, resolver, skipInlines);
+ else {
+ // Never skip empty inlines.
+ if (resolver)
+ resolver->commitExplicitEmbedding();
+ return o;
+ }
+ }
+
+ if (o && !o->isText() && !o->isReplaced() && !o->isFloating() && !o->isPositioned())
+ o = bidiNext(block, o, resolver, skipInlines);
+
+ if (resolver)
+ resolver->commitExplicitEmbedding();
+ return o;
+}
+
+inline void InlineIterator::increment(InlineBidiResolver* resolver)
+{
+ if (!obj)
+ return;
+ if (obj->isText()) {
+ pos++;
+ if (pos >= toRenderText(obj)->textLength()) {
+ obj = bidiNext(block, obj, resolver);
+ pos = 0;
+ nextBreakablePosition = -1;
+ }
+ } else {
+ obj = bidiNext(block, obj, resolver);
+ pos = 0;
+ nextBreakablePosition = -1;
+ }
+}
+
+inline bool InlineIterator::atEnd() const
+{
+ return !obj;
+}
+
+inline UChar InlineIterator::current() const
+{
+ if (!obj || !obj->isText())
+ return 0;
+
+ RenderText* text = toRenderText(obj);
+ if (pos >= text->textLength())
+ return 0;
+
+ return text->characters()[pos];
+}
+
+ALWAYS_INLINE WTF::Unicode::Direction InlineIterator::direction() const
+{
+ if (UChar c = current())
+ return WTF::Unicode::direction(c);
+
+ if (obj && obj->isListMarker())
+ return obj->style()->direction() == LTR ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
+
+ return WTF::Unicode::OtherNeutral;
+}
+
+template<>
+inline void InlineBidiResolver::increment()
+{
+ current.increment(this);
+}
+
+template <>
+inline void InlineBidiResolver::appendRun()
+{
+ if (!emptyRun && !eor.atEnd()) {
+ int start = sor.pos;
+ RenderObject *obj = sor.obj;
+ while (obj && obj != eor.obj && obj != endOfLine.obj) {
+ RenderBlock::appendRunsForObject(start, obj->length(), obj, *this);
+ start = 0;
+ obj = bidiNext(sor.block, obj);
+ }
+ if (obj) {
+ unsigned pos = obj == eor.obj ? eor.pos : UINT_MAX;
+ if (obj == endOfLine.obj && endOfLine.pos <= pos) {
+ reachedEndOfLine = true;
+ pos = endOfLine.pos;
+ }
+ // It's OK to add runs for zero-length RenderObjects, just don't make the run larger than it should be
+ int end = obj->length() ? pos+1 : 0;
+ RenderBlock::appendRunsForObject(start, end, obj, *this);
+ }
+
+ eor.increment();
+ sor = eor;
+ }
+
+ m_direction = WTF::Unicode::OtherNeutral;
+ m_status.eor = WTF::Unicode::OtherNeutral;
+}
+
+}
+
+#endif // InlineIterator_h
diff --git a/WebCore/rendering/RenderBlock.h b/WebCore/rendering/RenderBlock.h
index d7259ce..9134a19 100644
--- a/WebCore/rendering/RenderBlock.h
+++ b/WebCore/rendering/RenderBlock.h
@@ -138,6 +138,9 @@ public:
// style from this RenderBlock.
RenderBlock* createAnonymousBlock(bool isFlexibleBox = false) const;
+ static void appendRunsForObject(int start, int end, RenderObject*, InlineBidiResolver&);
+ static bool requiresLineBox(const InlineIterator&, bool isLineEmpty = true, bool previousLineBrokeCleanly = true);
+
protected:
void moveChildTo(RenderObject* to, RenderObjectChildList* toChildList, RenderObject* child);
void moveChildTo(RenderObject* to, RenderObjectChildList* toChildList, RenderObject* beforeChild, RenderObject* child);
diff --git a/WebCore/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp
index 8a1e1c9..191b24a 100644
--- a/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -24,6 +24,7 @@
#include "BidiResolver.h"
#include "CharacterNames.h"
+#include "InlineIterator.h"
#include "InlineTextBox.h"
#include "Logging.h"
#include "RenderArena.h"
@@ -46,36 +47,6 @@ namespace WebCore {
// We don't let our line box tree for a single line get any deeper than this.
const unsigned cMaxLineDepth = 200;
-class InlineIterator {
-public:
- InlineIterator()
- : block(0)
- , obj(0)
- , pos(0)
- , nextBreakablePosition(-1)
- {
- }
-
- InlineIterator(RenderBlock* b, RenderObject* o, unsigned p)
- : block(b)
- , obj(o)
- , pos(p)
- , nextBreakablePosition(-1)
- {
- }
-
- void increment(InlineBidiResolver* resolver = 0);
- bool atEnd() const;
-
- UChar current() const;
- Direction direction() const;
-
- RenderBlock* block;
- RenderObject* obj;
- unsigned pos;
- int nextBreakablePosition;
-};
-
static int getBorderPaddingMargin(RenderBoxModelObject* child, bool endOfInline)
{
bool leftSide = (child->style()->direction() == LTR) ? !endOfInline : endOfInline;
@@ -100,247 +71,6 @@ static int inlineWidth(RenderObject* child, bool start = true, bool end = true)
return extraWidth;
}
-struct BidiRun : BidiCharacterRun {
- BidiRun(int start, int stop, RenderObject* object, BidiContext* context, Direction dir)
- : BidiCharacterRun(start, stop, context, dir)
- , m_object(object)
- , m_box(0)
- {
- }
-
- void destroy();
-
- // Overloaded new operator.
- void* operator new(size_t, RenderArena*) throw();
-
- // Overridden to prevent the normal delete from being called.
- void operator delete(void*, size_t);
-
- BidiRun* next() { return static_cast<BidiRun*>(m_next); }
-
-private:
- // The normal operator new is disallowed.
- void* operator new(size_t) throw();
-
-public:
- RenderObject* m_object;
- InlineBox* m_box;
-};
-
-#ifndef NDEBUG
-static RefCountedLeakCounter bidiRunCounter("BidiRun");
-
-static bool inBidiRunDestroy;
-#endif
-
-void BidiRun::destroy()
-{
-#ifndef NDEBUG
- inBidiRunDestroy = true;
-#endif
- RenderArena* renderArena = m_object->renderArena();
- delete this;
-#ifndef NDEBUG
- inBidiRunDestroy = false;
-#endif
-
- // Recover the size left there for us by operator delete and free the memory.
- renderArena->free(*reinterpret_cast<size_t*>(this), this);
-}
-
-void* BidiRun::operator new(size_t sz, RenderArena* renderArena) throw()
-{
-#ifndef NDEBUG
- bidiRunCounter.increment();
-#endif
- return renderArena->allocate(sz);
-}
-
-void BidiRun::operator delete(void* ptr, size_t sz)
-{
-#ifndef NDEBUG
- bidiRunCounter.decrement();
-#endif
- ASSERT(inBidiRunDestroy);
-
- // Stash size where destroy() can find it.
- *(size_t*)ptr = sz;
-}
-
-// ---------------------------------------------------------------------
-
-inline bool operator==(const InlineIterator& it1, const InlineIterator& it2)
-{
- return it1.pos == it2.pos && it1.obj == it2.obj;
-}
-
-inline bool operator!=(const InlineIterator& it1, const InlineIterator& it2)
-{
- return it1.pos != it2.pos || it1.obj != it2.obj;
-}
-
-static inline RenderObject* bidiNext(RenderBlock* block, RenderObject* current, InlineBidiResolver* resolver = 0, bool skipInlines = true, bool* endOfInlinePtr = 0)
-{
- RenderObject* next = 0;
- bool oldEndOfInline = endOfInlinePtr ? *endOfInlinePtr : false;
- bool endOfInline = false;
-
- while (current) {
- next = 0;
- if (!oldEndOfInline && !current->isFloating() && !current->isReplaced() && !current->isPositioned() && !current->isText()) {
- next = current->firstChild();
- if (next && resolver && next->isRenderInline()) {
- EUnicodeBidi ub = next->style()->unicodeBidi();
- if (ub != UBNormal) {
- TextDirection dir = next->style()->direction();
- Direction d = (ub == Embed
- ? (dir == RTL ? RightToLeftEmbedding : LeftToRightEmbedding)
- : (dir == RTL ? RightToLeftOverride : LeftToRightOverride));
- resolver->embed(d);
- }
- }
- }
-
- if (!next) {
- if (!skipInlines && !oldEndOfInline && current->isRenderInline()) {
- next = current;
- endOfInline = true;
- break;
- }
-
- while (current && current != block) {
- if (resolver && current->isRenderInline() && current->style()->unicodeBidi() != UBNormal)
- resolver->embed(PopDirectionalFormat);
-
- next = current->nextSibling();
- if (next) {
- if (resolver && next->isRenderInline()) {
- EUnicodeBidi ub = next->style()->unicodeBidi();
- if (ub != UBNormal) {
- TextDirection dir = next->style()->direction();
- Direction d = (ub == Embed
- ? (dir == RTL ? RightToLeftEmbedding: LeftToRightEmbedding)
- : (dir == RTL ? RightToLeftOverride : LeftToRightOverride));
- resolver->embed(d);
- }
- }
- break;
- }
-
- current = current->parent();
- if (!skipInlines && current && current != block && current->isRenderInline()) {
- next = current;
- endOfInline = true;
- break;
- }
- }
- }
-
- if (!next)
- break;
-
- if (next->isText() || next->isFloating() || next->isReplaced() || next->isPositioned()
- || ((!skipInlines || !next->firstChild()) // Always return EMPTY inlines.
- && next->isRenderInline()))
- break;
- current = next;
- }
-
- if (endOfInlinePtr)
- *endOfInlinePtr = endOfInline;
-
- return next;
-}
-
-static RenderObject* bidiFirst(RenderBlock* block, InlineBidiResolver* resolver, bool skipInlines = true)
-{
- if (!block->firstChild())
- return 0;
-
- RenderObject* o = block->firstChild();
- if (o->isRenderInline()) {
- if (resolver) {
- EUnicodeBidi ub = o->style()->unicodeBidi();
- if (ub != UBNormal) {
- TextDirection dir = o->style()->direction();
- Direction d = (ub == Embed
- ? (dir == RTL ? RightToLeftEmbedding : LeftToRightEmbedding)
- : (dir == RTL ? RightToLeftOverride : LeftToRightOverride));
- resolver->embed(d);
- }
- }
- if (skipInlines && o->firstChild())
- o = bidiNext(block, o, resolver, skipInlines);
- else {
- // Never skip empty inlines.
- if (resolver)
- resolver->commitExplicitEmbedding();
- return o;
- }
- }
-
- if (o && !o->isText() && !o->isReplaced() && !o->isFloating() && !o->isPositioned())
- o = bidiNext(block, o, resolver, skipInlines);
-
- if (resolver)
- resolver->commitExplicitEmbedding();
- return o;
-}
-
-inline void InlineIterator::increment(InlineBidiResolver* resolver)
-{
- if (!obj)
- return;
- if (obj->isText()) {
- pos++;
- if (pos >= toRenderText(obj)->textLength()) {
- obj = bidiNext(block, obj, resolver);
- pos = 0;
- nextBreakablePosition = -1;
- }
- } else {
- obj = bidiNext(block, obj, resolver);
- pos = 0;
- nextBreakablePosition = -1;
- }
-}
-
-template<>
-inline void InlineBidiResolver::increment()
-{
- current.increment(this);
-}
-
-inline bool InlineIterator::atEnd() const
-{
- return !obj;
-}
-
-inline UChar InlineIterator::current() const
-{
- if (!obj || !obj->isText())
- return 0;
-
- RenderText* text = toRenderText(obj);
- if (pos >= text->textLength())
- return 0;
-
- return text->characters()[pos];
-}
-
-ALWAYS_INLINE Direction InlineIterator::direction() const
-{
- if (UChar c = current())
- return Unicode::direction(c);
-
- if (obj && obj->isListMarker())
- return obj->style()->direction() == LTR ? LeftToRight : RightToLeft;
-
- return OtherNeutral;
-}
-
-// -------------------------------------------------------------------------------------------------
-
static void chopMidpointsAt(LineMidpointState& lineMidpointState, RenderObject* obj, unsigned pos)
{
if (!lineMidpointState.numMidpoints)
@@ -398,7 +128,7 @@ static void addMidpoint(LineMidpointState& lineMidpointState, const InlineIterat
midpoints[lineMidpointState.numMidpoints++] = midpoint;
}
-static void appendRunsForObject(int start, int end, RenderObject* obj, InlineBidiResolver& resolver)
+void RenderBlock::appendRunsForObject(int start, int end, RenderObject* obj, InlineBidiResolver& resolver)
{
if (start > end || obj->isFloating() ||
(obj->isPositioned() && !obj->style()->hasStaticX() && !obj->style()->hasStaticY() && !obj->container()->isRenderInline()))
@@ -441,36 +171,6 @@ static void appendRunsForObject(int start, int end, RenderObject* obj, InlineBid
}
}
-template <>
-void InlineBidiResolver::appendRun()
-{
- if (!emptyRun && !eor.atEnd()) {
- int start = sor.pos;
- RenderObject *obj = sor.obj;
- while (obj && obj != eor.obj && obj != endOfLine.obj) {
- appendRunsForObject(start, obj->length(), obj, *this);
- start = 0;
- obj = bidiNext(sor.block, obj);
- }
- if (obj) {
- unsigned pos = obj == eor.obj ? eor.pos : UINT_MAX;
- if (obj == endOfLine.obj && endOfLine.pos <= pos) {
- reachedEndOfLine = true;
- pos = endOfLine.pos;
- }
- // It's OK to add runs for zero-length RenderObjects, just don't make the run larger than it should be
- int end = obj->length() ? pos+1 : 0;
- appendRunsForObject(start, end, obj, *this);
- }
-
- eor.increment();
- sor = eor;
- }
-
- m_direction = OtherNeutral;
- m_status.eor = OtherNeutral;
-}
-
static inline InlineBox* createInlineBoxForRenderer(RenderObject* obj, bool isRootLineBox, bool isOnlyRun = false)
{
if (isRootLineBox)
@@ -1444,7 +1144,7 @@ static bool inlineFlowRequiresLineBox(RenderInline* flow)
return !flow->firstChild() && flow->hasHorizontalBordersPaddingOrMargin();
}
-static inline bool requiresLineBox(const InlineIterator& it, bool isLineEmpty, bool previousLineBrokeCleanly)
+bool RenderBlock::requiresLineBox(const InlineIterator& it, bool isLineEmpty, bool previousLineBrokeCleanly)
{
if (it.obj->isFloatingOrPositioned())
return false;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list