WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-109825-20130214144357.patch (text/plain), 11.00 KB, created by
Anton Vayvod
on 2013-02-14 06:47:30 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Anton Vayvod
Created:
2013-02-14 06:47:30 PST
Size:
11.00 KB
patch
obsolete
>Subversion Revision: 142873 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d13dcc263288c07fa8b92d3213f04a66edba6cb0..122db5eaca1b79d7bb12a9bf295b0ab880c7cc56 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2013-02-14 Anton Vayvod <avayvod@chromium.org> >+ >+ [Text Autosizing] Combine narrow descendants of a cluster into groups that should be autosized with the same multiplier. >+ https://bugs.webkit.org/show_bug.cgi?id=109825 >+ >+ Enhancement of the approach introduced in https://bugs.webkit.org/show_bug.cgi?id=109573. >+ Instead of using the same text size multiplier for all narrow descendants of any autosizing >+ cluster, group the descendants by how much narrower they are than the cluster's >+ |blockContainingAllText| and process each group separately with a different multiplier for >+ each one. >+ For example, we want nested comments on the page to be autosized as a group but separately >+ from a sidebar on the same page. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Updated the existing test to verify the patch. >+ >+ * rendering/TextAutosizer.cpp: >+ (WebCore::TextAutosizer::processClusterInternal): >+ >+ Splits the narrow descendants of the autosizing cluster into groups before processing >+ each group individually. >+ >+ (WebCore::TextAutosizer::getNarrowDescendantsGroupedByDifferenceFromParentTextWidth): >+ >+ Sorts the narrow descendants of the given cluster into groups, combining them by the >+ difference between the width of the cluster's |blockContainingAllText| and the width of >+ the descendant. If this difference is called |delta|, two descendants belong to >+ different groups if the difference between their deltas is greater than 100 (in CSS >+ units). >+ >+ * rendering/TextAutosizer.h: >+ >+ New method definitions. >+ > 2013-02-14 Yury Semikhatsky <yurys@chromium.org> > > Web Inspector: don't create static local string for program literal in InspectorTimelineAgent >diff --git a/Source/WebCore/rendering/TextAutosizer.cpp b/Source/WebCore/rendering/TextAutosizer.cpp >index 342637aaabefa5c1de6254ed6a0375d961239735..5d0641b8aa96d981a3a697ead7edd979ae703801 100644 >--- a/Source/WebCore/rendering/TextAutosizer.cpp >+++ b/Source/WebCore/rendering/TextAutosizer.cpp >@@ -149,7 +149,10 @@ void TextAutosizer::processClusterInternal(TextAutosizingClusterInfo& clusterInf > > processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo); > >- processCompositeCluster(clusterInfo.narrowDescendants, windowInfo); >+ Vector<Vector<TextAutosizingClusterInfo> > narrowDescendantsGroups; >+ getNarrowDescendantsGroupedByDifferenceFromParentTextWidth(clusterInfo, narrowDescendantsGroups); >+ for (size_t i = 0; i < narrowDescendantsGroups.size(); ++i) >+ processCompositeCluster(narrowDescendantsGroups[i], windowInfo); > } > > void TextAutosizer::processCluster(TextAutosizingClusterInfo& clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo) >@@ -556,6 +559,62 @@ const RenderObject* TextAutosizer::findFirstTextLeafNotInCluster(const RenderObj > return 0; > } > >+namespace { >+ >+class CompareIndicesByWidthDifference { >+public: >+ explicit CompareIndicesByWidthDifference(const Vector<float>& diffs): m_diffs(diffs) { } >+ >+ bool operator()(size_t index1, size_t index2) const >+ { >+ return m_diffs[index1] < m_diffs[index2]; >+ } >+ >+private: >+ const Vector<float>& m_diffs; >+}; >+ >+} // namespace >+ >+void TextAutosizer::getNarrowDescendantsGroupedByDifferenceFromParentTextWidth(const TextAutosizingClusterInfo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >& groups) >+{ >+ ASSERT(parentClusterInfo.blockContainingAllText); >+ ASSERT(groups.isEmpty()); >+ >+ const Vector<TextAutosizingClusterInfo>& clusterInfos = parentClusterInfo.narrowDescendants; >+ const float maxDifferenceWithinGroup = 100; >+ >+ Vector<float> differencesFromParentTextWidth; >+ differencesFromParentTextWidth.reserveInitialCapacity(clusterInfos.size()); >+ >+ Vector<size_t> clusterIndices; >+ clusterIndices.reserveInitialCapacity(clusterInfos.size()); >+ >+ for (size_t i = 0; i < clusterInfos.size(); ++i) { >+ float clusterWidth = clusterInfos[i].root->contentLogicalWidth(); >+ float parentTextWidth = parentClusterInfo.blockContainingAllText->contentLogicalWidth(); >+ differencesFromParentTextWidth.append(parentTextWidth - clusterWidth); >+ clusterIndices.append(i); >+ } >+ std::sort(clusterIndices.begin(), clusterIndices.end(), CompareIndicesByWidthDifference(differencesFromParentTextWidth)); >+ >+ for (size_t i = 0; i < clusterIndices.size(); ++i) { >+ if (groups.isEmpty()) >+ groups.append(Vector<TextAutosizingClusterInfo>()); >+ >+ size_t currentIndex = clusterIndices[i]; >+ const TextAutosizingClusterInfo& currentClusterInfo = clusterInfos[currentIndex]; >+ groups.last().append(currentClusterInfo); >+ >+ if (i + 1 < clusterIndices.size()) { >+ float currentWidthDifference = differencesFromParentTextWidth[currentIndex]; >+ float nextWidthDifference = differencesFromParentTextWidth[clusterIndices[i + 1]]; >+ if (nextWidthDifference - currentWidthDifference > maxDifferenceWithinGroup) >+ groups.append(Vector<TextAutosizingClusterInfo>()); >+ } >+ } >+} >+ > } // namespace WebCore > > #endif // ENABLE(TEXT_AUTOSIZING) >diff --git a/Source/WebCore/rendering/TextAutosizer.h b/Source/WebCore/rendering/TextAutosizer.h >index 6495a302b087e77c7808eab213f362eec3fbba7b..96f2690ddac956ed802de5a4fb6d36afa3200fe3 100644 >--- a/Source/WebCore/rendering/TextAutosizer.h >+++ b/Source/WebCore/rendering/TextAutosizer.h >@@ -91,6 +91,11 @@ private: > // belong to any cluster. > static const RenderObject* findFirstTextLeafNotInCluster(const RenderObject*, size_t& depth, TraversalDirection); > >+ // Returns groups of narrow descendants of a given autosizing cluster. The groups are combined >+ // by the difference between the width of the descendant and the width of the parent cluster's >+ // |blockContainingAllText|. >+ static void getNarrowDescendantsGroupedByDifferenceFromParentTextWidth(const TextAutosizingClusterInfo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >&); >+ > Document* m_document; > }; > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 859ec482490fc6e2b568642519557ee6ef4a7379..91187ee8194f31e280c0b132227f7fd14d44d34e 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2013-02-14 Anton Vayvod <avayvod@chromium.org> >+ >+ [Text Autosizing] Combine narrow descendants of a cluster into groups that should be autosized with the same multiplier. >+ https://bugs.webkit.org/show_bug.cgi?id=109825 >+ >+ Verify that narrow descendants are grouped and autosized separately according to the >+ difference between the descendant's width and the width of its enclosing cluster's >+ |blockContainingAllText|. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/text-autosizing/narrow-descendants-combined-expected.html: >+ * fast/text-autosizing/narrow-descendants-combined.html: >+ > 2013-02-14 Vsevolod Vlasov <vsevik@chromium.org> > > Web Inspector: Remove uriForFile and fileForURI methods from FileSystemMapping. >diff --git a/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html b/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html >index 48fc24b5da87e2540009dba09378d346d28afdef..1237aee56f4b589baf7d6e91a660ac4151fb26e0 100644 >--- a/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html >+++ b/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html >@@ -13,13 +13,15 @@ body { width: 800px; margin: 0; overflow-y: hidden; } > > <div style="font-size: 1.25rem"> > <div style="width: 320px"> >- This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px. >+ This text should be autosized to 20px computed font-size as it is combined with the last narrow sibling and the maximum width is 400px. > </div> >- <div style="width: 400px"> >- This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px. >+ <div style="width: 560px; font-size: 1.75rem"> >+ This text should be autosized to 28px computed font-size as it is combined into a separate group from its two siblings since it's significantly wider.<br> >+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. > </div> >- <div style="width: 240px"> >- This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px. >+ <div style="width: 400px"> >+ This text should be autosized to 20px computed font-size as it is combined with the first narrow sibling and the maximum width is 400px.<br> >+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. > </div> > </div> > >diff --git a/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html b/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html >index 5aac36b6b68205615c907264943461f54d858609..f54642bece44de08ecda9082d3d72f39922d6d11 100644 >--- a/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html >+++ b/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html >@@ -22,13 +22,15 @@ if (window.internals) { > > <div> > <div style="width: 320px"> >- This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px. >+ This text should be autosized to 20px computed font-size as it is combined with the last narrow sibling and the maximum width is 400px. > </div> >- <div style="width: 400px"> >- This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px. >+ <div style="width: 560px"> >+ This text should be autosized to 28px computed font-size as it is combined into a separate group from its two siblings since it's significantly wider.<br> >+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. > </div> >- <div style="width: 240px"> >- This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px. >+ <div style="width: 400px"> >+ This text should be autosized to 20px computed font-size as it is combined with the first narrow sibling and the maximum width is 400px.<br> >+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. > </div> > </div> >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 109825
:
188339
|
188887
|
188893
|
188924