[LayoutReloaded] Add InlineTextBreaker::skipLeadingWhitespaceIfNeeded
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2018 18:30:15 +0000 (18:30 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2018 18:30:15 +0000 (18:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184099

Reviewed by Antti Koivisto.

* LayoutReloaded/misc/LayoutReloadedWebKit.patch:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230037 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/LayoutReloaded/misc/LayoutReloadedWebKit.patch

index f70ca029b345d6755415feb72cb4e64d054058ea..bbf7bf862b085af5679437bd2f601d2f4b8aad26 100644 (file)
@@ -1,3 +1,12 @@
+2018-03-28  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutReloaded] Add InlineTextBreaker::skipLeadingWhitespaceIfNeeded
+        https://bugs.webkit.org/show_bug.cgi?id=184099
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LayoutReloadedWebKit.patch:
+
 2018-03-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GLIB] Add JSCWeakValue to JavaScriptCore GLib API
index 611d3f0570b4155489b242aaf1e885ca38f19c84..4f54d18201e0aef6d8173121fd1a6c453ac23ab2 100644 (file)
@@ -1,8 +1,8 @@
 diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
-index 84bc44c7450..d3ea1e02f9a 100644
+index 290f6de219b..f7411e2dfb4 100644
 --- a/Source/WTF/wtf/Platform.h
 +++ b/Source/WTF/wtf/Platform.h
-@@ -1119,7 +1119,7 @@
+@@ -1120,7 +1120,7 @@
  #if !defined(NDEBUG)
  #define ENABLE_TREE_DEBUGGING 1
  #else
@@ -38,7 +38,7 @@ index 02da4cb443c..aa757fcb42e 100644
  rendering/LayoutRepainter.cpp
  rendering/LayoutState.cpp
 diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
-index 9bb56f01a81..aa103d8d782 100644
+index f899f092389..2cd59716f8f 100644
 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 @@ -397,6 +397,10 @@
@@ -424,7 +424,7 @@ index 25177a8cd43..294307dc815 100644
      DOMString? lookupNamespaceURI(DOMString? prefix);
      boolean isDefaultNamespace(DOMString? namespaceURI);
 diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp
-index 31fb95c4c62..82e538fc68f 100644
+index 2d423cf4fd3..2c292aefdc2 100644
 --- a/Source/WebCore/page/DOMWindow.cpp
 +++ b/Source/WebCore/page/DOMWindow.cpp
 @@ -29,6 +29,7 @@
@@ -641,10 +641,10 @@ index 0b26444903f..595203b201e 100644
  
 diff --git a/Source/WebCore/rendering/InlineTextBreaker.cpp b/Source/WebCore/rendering/InlineTextBreaker.cpp
 new file mode 100644
-index 00000000000..4abbf429149
+index 00000000000..9ac083d2a90
 --- /dev/null
 +++ b/Source/WebCore/rendering/InlineTextBreaker.cpp
-@@ -0,0 +1,294 @@
+@@ -0,0 +1,308 @@
 +/*
 + * Copyright (C) 2018 Apple Inc. All rights reserved.
 + *
@@ -867,10 +867,24 @@ index 00000000000..4abbf429149
 +    runToSplit.setWidth(splitRunData.width);
 +}
 +
++unsigned InlineTextBreaker::skipLeadingWhitespaceIfNeeded() const
++{
++    if (!m_style.collapseWhitespace)
++        return 0;
++
++    for (unsigned index = 0; index < m_textRuns.size(); ++index) {
++        if (m_textRuns[index]->type() != InlineTextRun::Whitespace)
++            return index;
++    }
++    return m_textRuns.size();
++}
++
 +Vector<Ref<InlineTextRun>> InlineTextBreaker::createAndCollectLineRuns()
 +{
 +    bool lineCanBeWrapped = m_style.wrapLines || m_style.breakFirstWordOnOverflow || m_style.breakAnyWordOnOverflow;
-+    for (auto& run : m_textRuns) {
++    auto index = skipLeadingWhitespaceIfNeeded();
++    for (; index < m_textRuns.size(); ++index) {
++        auto& run = m_textRuns[index];
 +        // Hard and soft linebreaks.
 +        if (run->type() == InlineTextRun::SoftLineBreak) {
 +            // Add the new line fragment only if there's nothing on the line. (otherwise the extra new line character would show up at the end of the content.)
@@ -941,10 +955,10 @@ index 00000000000..4abbf429149
 +}
 diff --git a/Source/WebCore/rendering/InlineTextBreaker.h b/Source/WebCore/rendering/InlineTextBreaker.h
 new file mode 100644
-index 00000000000..fc0f0b2772e
+index 00000000000..8cf678fd5c5
 --- /dev/null
 +++ b/Source/WebCore/rendering/InlineTextBreaker.h
-@@ -0,0 +1,96 @@
+@@ -0,0 +1,97 @@
 +/*
 + * Copyright (C) 2018 Apple Inc. All rights reserved.
 + *
@@ -996,6 +1010,7 @@ index 00000000000..fc0f0b2772e
 +    void removeTrailingWhitespace();
 +    bool preWrap() const;
 +    float textWidth(unsigned from, unsigned to) const;
++    unsigned skipLeadingWhitespaceIfNeeded() const;
 +
 +    struct Style {
 +        explicit Style(const RenderStyle&);