Title: [159032] trunk/Source/WebCore
- Revision
- 159032
- Author
- [email protected]
- Date
- 2013-11-10 15:32:48 -0800 (Sun, 10 Nov 2013)
Log Message
Use start/end instead of textOffset/textLength for simple text runs
https://bugs.webkit.org/show_bug.cgi?id=124130
Reviewed by Oliver Hunt.
The code reads better this way.
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::createTextRuns):
* rendering/SimpleLineLayout.h:
(WebCore::SimpleLineLayout::Run::Run):
* rendering/SimpleLineLayoutFunctions.h:
(WebCore::SimpleLineLayout::findTextCaretMinimumOffset):
(WebCore::SimpleLineLayout::findTextCaretMaximumOffset):
(WebCore::SimpleLineLayout::containsTextCaretOffset):
(WebCore::SimpleLineLayout::isTextRendered):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::text):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (159031 => 159032)
--- trunk/Source/WebCore/ChangeLog 2013-11-10 22:28:10 UTC (rev 159031)
+++ trunk/Source/WebCore/ChangeLog 2013-11-10 23:32:48 UTC (rev 159032)
@@ -1,5 +1,26 @@
2013-11-10 Antti Koivisto <[email protected]>
+ Use start/end instead of textOffset/textLength for simple text runs
+ https://bugs.webkit.org/show_bug.cgi?id=124130
+
+ Reviewed by Oliver Hunt.
+
+ The code reads better this way.
+
+ * rendering/SimpleLineLayout.cpp:
+ (WebCore::SimpleLineLayout::createTextRuns):
+ * rendering/SimpleLineLayout.h:
+ (WebCore::SimpleLineLayout::Run::Run):
+ * rendering/SimpleLineLayoutFunctions.h:
+ (WebCore::SimpleLineLayout::findTextCaretMinimumOffset):
+ (WebCore::SimpleLineLayout::findTextCaretMaximumOffset):
+ (WebCore::SimpleLineLayout::containsTextCaretOffset):
+ (WebCore::SimpleLineLayout::isTextRendered):
+ * rendering/SimpleLineLayoutResolver.h:
+ (WebCore::SimpleLineLayout::RunResolver::Run::text):
+
+2013-11-10 Antti Koivisto <[email protected]>
+
Implement white-space property on simple line layout path
https://bugs.webkit.org/show_bug.cgi?id=124122
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (159031 => 159032)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2013-11-10 22:28:10 UTC (rev 159031)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2013-11-10 23:32:48 UTC (rev 159032)
@@ -310,7 +310,7 @@
if (wordStart > lineStart)
lineRuns.append(Run(lineEnd, lineRuns.last().right));
lineRuns.last().right = lineRuns.last().left;
- lineRuns.last().textLength = 1;
+ lineRuns.last().end = lineEnd + 1;
lineEnd = wordEnd;
break;
}
@@ -343,7 +343,7 @@
// Include newline to this run too.
if (whitespaceEnd < textLength && text[whitespaceEnd] == '\n')
++whitespaceEnd;
- lineRuns.last().textLength = whitespaceEnd - lineRuns.last().textOffset;
+ lineRuns.last().end = whitespaceEnd;
lineRuns.last().right = lineWidth.availableWidth();
lineEnd = whitespaceEnd;
break;
@@ -355,7 +355,7 @@
// There were more than one consecutive whitespace.
ASSERT(wordIsPrecededByWhitespace);
// Include space to the end of the previous run.
- lineRuns.last().textLength++;
+ lineRuns.last().end++;
lineRuns.last().right += spaceWidth;
// Start a new run on the same line.
lineRuns.append(Run(wordStart + 1, lineRuns.last().right));
@@ -364,7 +364,7 @@
lineWidth.commit();
lineRuns.last().right = lineWidth.committedWidth();
- lineRuns.last().textLength = wordEnd - lineRuns.last().textOffset;
+ lineRuns.last().end = wordEnd;
lineEnd = wordEnd;
if (collapseWhitespace)
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (159031 => 159032)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.h 2013-11-10 22:28:10 UTC (rev 159031)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h 2013-11-10 23:32:48 UTC (rev 159032)
@@ -44,16 +44,16 @@
struct Run {
Run() { }
- Run(unsigned textOffset, float left)
- : textOffset(textOffset)
- , textLength(0)
+ Run(unsigned start, float left)
+ : start(start)
+ , end(start)
, isEndOfLine(false)
, left(left)
, right(left)
{ }
- unsigned textOffset;
- unsigned textLength : 31;
+ unsigned start;
+ unsigned end : 31;
unsigned isEndOfLine : 1;
float left;
float right;
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h (159031 => 159032)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h 2013-11-10 22:28:10 UTC (rev 159031)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h 2013-11-10 23:32:48 UTC (rev 159032)
@@ -84,7 +84,7 @@
{
if (!layout.runCount())
return 0;
- return layout.runAt(0).textOffset;
+ return layout.runAt(0).start;
}
inline unsigned findTextCaretMaximumOffset(const RenderText& renderer, const Layout& layout)
@@ -92,16 +92,16 @@
if (!layout.runCount())
return renderer.textLength();
auto& last = layout.runAt(layout.runCount() - 1);
- return last.textOffset + last.textLength;
+ return last.end;
}
inline bool containsTextCaretOffset(const RenderText&, const Layout& layout, unsigned offset)
{
for (unsigned i = 0; i < layout.runCount(); ++i) {
auto& run = layout.runAt(i);
- if (offset < run.textOffset)
+ if (offset < run.start)
return false;
- if (offset <= run.textOffset + run.textLength)
+ if (offset <= run.end)
return true;
}
return false;
@@ -110,7 +110,8 @@
inline bool isTextRendered(const RenderText&, const Layout& layout)
{
for (unsigned i = 0; i < layout.runCount(); ++i) {
- if (layout.runAt(i).textLength)
+ auto& run = layout.runAt(i);
+ if (run.end > run.start)
return true;
}
return false;
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (159031 => 159032)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2013-11-10 22:28:10 UTC (rev 159031)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2013-11-10 23:32:48 UTC (rev 159032)
@@ -148,7 +148,7 @@
{
auto& resolver = m_iterator.resolver();
auto& run = m_iterator.simpleRun();
- return resolver.m_string.substringSharingImpl(run.textOffset, run.textLength);
+ return resolver.m_string.substringSharingImpl(run.start, run.end - run.start);
}
inline unsigned RunResolver::Run::lineIndex() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes