Title: [231384] trunk/Source/WebCore
- Revision
- 231384
- Author
- za...@apple.com
- Date
- 2018-05-04 15:23:47 -0700 (Fri, 04 May 2018)
Log Message
[Simple line layout] Add support for line layout box generation with multiple text renderers.
https://bugs.webkit.org/show_bug.cgi?id=185276
Reviewed by Antti Koivisto.
Covered by existing tests.
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::canUseForLineBoxTree):
(WebCore::SimpleLineLayout::generateLineBoxTree):
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::Run::renderer const):
(WebCore::SimpleLineLayout::RunResolver::Run::localStart const):
(WebCore::SimpleLineLayout::RunResolver::Run::localEnd const):
* rendering/SimpleLineLayoutResolver.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (231383 => 231384)
--- trunk/Source/WebCore/ChangeLog 2018-05-04 21:43:21 UTC (rev 231383)
+++ trunk/Source/WebCore/ChangeLog 2018-05-04 22:23:47 UTC (rev 231384)
@@ -1,3 +1,21 @@
+2018-05-04 Zalan Bujtas <za...@apple.com>
+
+ [Simple line layout] Add support for line layout box generation with multiple text renderers.
+ https://bugs.webkit.org/show_bug.cgi?id=185276
+
+ Reviewed by Antti Koivisto.
+
+ Covered by existing tests.
+
+ * rendering/SimpleLineLayoutFunctions.cpp:
+ (WebCore::SimpleLineLayout::canUseForLineBoxTree):
+ (WebCore::SimpleLineLayout::generateLineBoxTree):
+ * rendering/SimpleLineLayoutResolver.cpp:
+ (WebCore::SimpleLineLayout::RunResolver::Run::renderer const):
+ (WebCore::SimpleLineLayout::RunResolver::Run::localStart const):
+ (WebCore::SimpleLineLayout::RunResolver::Run::localEnd const):
+ * rendering/SimpleLineLayoutResolver.h:
+
2018-05-04 Timothy Hatcher <timo...@apple.com>
Deprecate legacy WebView and friends
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (231383 => 231384)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp 2018-05-04 21:43:21 UTC (rev 231383)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp 2018-05-04 22:23:47 UTC (rev 231384)
@@ -38,6 +38,7 @@
#include "LineInfo.h"
#include "PaintInfo.h"
#include "RenderBlockFlow.h"
+#include "RenderChildIterator.h"
#include "RenderIterator.h"
#include "RenderStyle.h"
#include "RenderText.h"
@@ -283,12 +284,13 @@
if (!flow.firstChild())
return false;
- if (flow.firstChild() != flow.lastChild())
- return false;
-
- if (!is<RenderText>(*flow.firstChild()))
- return false;
-
+ for (auto& child : childrenOfType<RenderObject>(flow)) {
+ if (!is<RenderText>(child))
+ return false;
+ // Simple line layout iterator can't handle renderers with zero length properly.
+ if (!downcast<RenderText>(child).length())
+ return false;
+ }
return true;
}
@@ -331,7 +333,7 @@
BidiRunList<BidiRun> bidiRuns;
for (auto it = range.begin(); it != range.end(); ++it) {
auto run = *it;
- bidiRuns.appendRun(std::make_unique<BidiRun>(run.start(), run.end(), *flow.firstChild(), bidiContext.ptr(), U_LEFT_TO_RIGHT));
+ bidiRuns.appendRun(std::make_unique<BidiRun>(run.localStart(), run.localEnd(), const_cast<RenderObject&>(run.renderer()), bidiContext.ptr(), U_LEFT_TO_RIGHT));
}
LineInfo lineInfo;
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (231383 => 231384)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp 2018-05-04 21:43:21 UTC (rev 231383)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp 2018-05-04 22:23:47 UTC (rev 231384)
@@ -88,6 +88,30 @@
return StringView(segment.text).substring(segment.toSegmentPosition(run.start), run.end - run.start);
}
+const RenderObject& RunResolver::Run::renderer() const
+{
+ auto& run = m_iterator.simpleRun();
+ // FlowContents cannot differentiate empty runs.
+ ASSERT(run.start != run.end);
+ return m_iterator.resolver().m_flowContents.segmentForRun(run.start, run.end).renderer;
+}
+
+unsigned RunResolver::Run::localStart() const
+{
+ auto& run = m_iterator.simpleRun();
+ // FlowContents cannot differentiate empty runs.
+ ASSERT(run.start != run.end);
+ return m_iterator.resolver().m_flowContents.segmentForRun(run.start, run.end).toSegmentPosition(run.start);
+}
+
+unsigned RunResolver::Run::localEnd() const
+{
+ auto& run = m_iterator.simpleRun();
+ // FlowContents cannot differentiate empty runs.
+ ASSERT(run.start != run.end);
+ return m_iterator.resolver().m_flowContents.segmentForRun(run.start, run.end).toSegmentPosition(run.end);
+}
+
RunResolver::Iterator::Iterator(const RunResolver& resolver, unsigned runIndex, unsigned lineIndex)
: m_resolver(resolver)
, m_runIndex(runIndex)
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (231383 => 231384)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2018-05-04 21:43:21 UTC (rev 231383)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2018-05-04 22:23:47 UTC (rev 231384)
@@ -43,8 +43,13 @@
public:
explicit Run(const Iterator&);
+ // Position relative to the enclosing flow block.
unsigned start() const;
unsigned end() const;
+ // Position relative to the actual renderer.
+ unsigned localStart() const;
+ unsigned localEnd() const;
+
float logicalLeft() const;
float logicalRight() const;
@@ -54,6 +59,7 @@
int baselinePosition() const;
StringView text() const;
String textWithHyphen() const;
+ const RenderObject& renderer() const;
bool isEndOfLine() const;
bool hasHyphen() const { return m_iterator.simpleRun().hasHyphen; }
const SimpleLineLayout::Run& simpleRun() const { return m_iterator.simpleRun(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes