Title: [127131] trunk
Revision
127131
Author
[email protected]
Date
2012-08-30 06:19:42 -0700 (Thu, 30 Aug 2012)

Log Message

[CSSRegions]Add support for text-shadow in region styling
https://bugs.webkit.org/show_bug.cgi?id=94472

Patch by Andrei Onea <[email protected]> on 2012-08-30
Reviewed by David Hyatt.

Source/WebCore:

The CSSRegions spec allows region styling to be applied on the text-shadow property
as well. We need to also add this in WebKit.

Test: fast/regions/region-style-text-shadow.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRulesForList):
Make sure we actually collect text-shadow property from parser in an @region rule.
* rendering/InlineBox.cpp:
(WebCore::InlineBox::styleInRegion):
(WebCore):
(WebCore::InlineBox::regionDuringLayout):
* rendering/InlineBox.h:
(WebCore):
(InlineBox):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::addToLine):
Take into account region styling, so that "knownToHaveNoOverflow" is computed
properly.
(WebCore::InlineFlowBox::addTextBoxVisualOverflow):
Take into account region styling, so that the visual overflow rect is computed
properly.
* rendering/RenderRegion.h:
(RenderRegion):
Made computeStyleInRegion public.

LayoutTests:

Added test for region styling on the text shadow property.

* fast/regions/region-style-text-shadow-expected.html: Added.
* fast/regions/region-style-text-shadow.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (127130 => 127131)


--- trunk/LayoutTests/ChangeLog	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/LayoutTests/ChangeLog	2012-08-30 13:19:42 UTC (rev 127131)
@@ -1,3 +1,15 @@
+2012-08-30  Andrei Onea  <[email protected]>
+
+        [CSSRegions]Add support for text-shadow in region styling
+        https://bugs.webkit.org/show_bug.cgi?id=94472
+
+        Reviewed by David Hyatt.
+
+        Added test for region styling on the text shadow property.
+
+        * fast/regions/region-style-text-shadow-expected.html: Added.
+        * fast/regions/region-style-text-shadow.html: Added.
+
 2012-08-30  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/fast/regions/region-style-text-shadow-expected.html (0 => 127131)


--- trunk/LayoutTests/fast/regions/region-style-text-shadow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/region-style-text-shadow-expected.html	2012-08-30 13:19:42 UTC (rev 127131)
@@ -0,0 +1,47 @@
+<!doctype html>
+ <html>
+     <!--
+     Test for https://bugs.webkit.org/show_bug.cgi?id=94472 ([CSSRegions]Add support for text-shadow in region styling).
+     You should not see any red text below.
+     -->
+     <head>
+         <style>
+             body { font-family: monospace; }
+             #p1 { text-shadow: 340px 100px #008000; position: absolute; top: 10px; }
+             #span2 { text-shadow: 340px 100px #008000; position: absolute; top: 50px; }
+             #article3 { text-shadow: 340px 100px #0000ff; position: absolute; top: 90px; }
+             #div3 { text-shadow: 340px 100px #008000; }
+             em { text-shadow: 340px 100px #008000; }
+             #div4 { position: absolute; top: 140px; width: 340px; height: 40px; }
+             #p4 { text-shadow: 340px 100px #0000ff; }
+             #div51 { position: absolute; top: 190px; width: 340px; height: 40px; }
+             #div52 { text-shadow: 340px 100px #0000ff; }
+             #div6 { position: absolute; top: 240px; width: 340px; height: 40px; }
+             #div7 { position: absolute; top: 290px; width: 340px; height: 40px; text-shadow: 340px 100px #0000ff, 0px 100px #0000ff, 340px 0px #0000ff; }
+         </style>
+     </head>
+     <body>
+ 		<p id="p1">P shadow styled in region: #008000.</p>
+ 		<span id="span2">Span shadow styled in region: #008000.</span>
+         <div id="article3">
+             Text shadow styled in region: #0000ff.
+             <div id="div3">Div shadow styled in region: #008000.</div>
+             Text shadow styled in region: #0000ff.
+         </div>       
+
+         <div id="div4">
+            Text without shadow.
+            <p id="p4">P shadow styled in region: #0000ff.</p>
+        </div>
+        <div id="div51">
+            Text without shadow.
+            <div id="div52">Div shadow styled in region: #0000ff.</div>
+        </div>
+        <div id="div6">
+            Text with removed shadow due to region styling.
+        </div>
+        <div id="div7">
+                Text with multiple shadows.
+        </div>
+     </body>
+ </html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/regions/region-style-text-shadow.html (0 => 127131)


--- trunk/LayoutTests/fast/regions/region-style-text-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/region-style-text-shadow.html	2012-08-30 13:19:42 UTC (rev 127131)
@@ -0,0 +1,103 @@
+<!doctype html>
+ <html>
+     <!--
+     Test for https://bugs.webkit.org/show_bug.cgi?id=94472 ([CSSRegions]Add support for text-shadow in region styling).
+     You should not see any red shadows below.
+     -->
+     <head>
+         <style>
+             body { font-family: monospace; }
+             .regionBox { width: 340px; height: 24px; }
+             .regionBox2 { width: 340px; height: 40px; }
+ 
+             #article1 { -webkit-flow-into: flow1; }
+             #region1 { -webkit-flow-from: flow1; position: absolute; top: 10px; }
+             #p1 { text-shadow: 340px 100px #ff0000; }
+             @-webkit-region #region1 {
+                 #p1 { text-shadow: 340px 100px #008000; }
+             }
+ 
+             #article2 { -webkit-flow-into: flow2; }
+             #region2 { -webkit-flow-from: flow2; position: absolute; top: 50px; }
+             #span2 { text-shadow: 340px 100px #ff0000; }
+             @-webkit-region #region2 {
+                 #span2 { text-shadow: 340px 100px #008000; }
+             }
+ 
+             #article3 { -webkit-flow-into: flow3; }
+             #region3 { -webkit-flow-from: flow3; position: absolute; top: 90px; }
+             #article3 { text-shadow: 340px 100px #ff0000; }
+             @-webkit-region #region3 {
+                 #article3 { text-shadow: 340px 100px #0000ff; }
+                 #div3 { text-shadow: 340px 100px #008000; }
+             }
+             #article4 { -webkit-flow-into: flow4; }
+             #p4 { text-shadow: 340px 100px #ff0000; }
+             #region4 { -webkit-flow-from: flow4; position: absolute; top: 140px; }
+              @-webkit-region #region4 {
+                 #p4 { text-shadow: 340px 100px #0000ff; }
+             }
+
+             #article5 { -webkit-flow-into: flow5; }
+             #div5 { text-shadow: 340px 100px #ff0000; }
+             #region5 { -webkit-flow-from: flow5; position: absolute; top: 190px; }
+              @-webkit-region #region5 {
+                 #div5 { text-shadow: 340px 100px #0000ff; }
+             }
+             #article6 { -webkit-flow-into: flow6; }
+             #div6 { text-shadow: 340px 100px #ff0000; }
+             #region6 { -webkit-flow-from: flow6; position: absolute; top: 240px; }
+             @-webkit-region #region6 {
+                 #div6 { text-shadow: none; }
+             }
+             #article7 { -webkit-flow-into: flow7; }
+             #div7 { text-shadow: 340px 100px #ff0000; }
+             #region7 { -webkit-flow-from: flow7; position: absolute; top: 290px; }
+             @-webkit-region #region7 {
+                 #div7 { text-shadow: 340px 100px #0000ff, 0px 100px #0000ff, 340px 0px #0000ff; }
+             }
+         </style>
+     </head>
+     <body>
+         <div id="article1">
+             <p id="p1">P shadow styled in region: #008000.</p>
+         </div>
+         <div id="region1" class="regionBox"></div>
+ 
+         <div id="article2">
+             <span id="span2">Span shadow styled in region: #008000.</span>
+         </div>
+         <div id="region2" class="regionBox"></div>
+ 
+         <div id="article3">
+             Text shadow styled in region: #0000ff.
+             <div id="div3">Div shadow styled in region: #008000.</div>
+             Text shadow styled in region: #0000ff.
+         </div>
+         <div id="region3" class="regionBox2"></div>
+         <div id="region41" class="regionBox2"></div>
+         <div id="region42" class="regionBox2"></div>
+         <div id="article4">
+            Text without shadow.
+            <p id="p4">P shadow styled in region: #0000ff.</p>
+         </div>
+         <div id="region4" class="regionBox2"></div>
+         <div id="article5">
+            Text without shadow.
+            <div id="div5">Div shadow styled in region: #0000ff.</div>
+         </div>
+         <div id="region5" class="regionBox2"></div>
+         <div id="article6">
+            <div id="div6">
+                Text with removed shadow due to region styling.
+            </div>
+        </div>
+        <div id="region6" class="regionBox"></div>
+        <div id="article7">
+            <div id="div7">
+                Text with multiple shadows.
+            </div>
+        </div>
+        <div id="region7" class="regionBox"></div>
+     </body>
+ </html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (127130 => 127131)


--- trunk/Source/WebCore/ChangeLog	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/Source/WebCore/ChangeLog	2012-08-30 13:19:42 UTC (rev 127131)
@@ -1,3 +1,36 @@
+2012-08-30  Andrei Onea  <[email protected]>
+
+        [CSSRegions]Add support for text-shadow in region styling
+        https://bugs.webkit.org/show_bug.cgi?id=94472
+
+        Reviewed by David Hyatt.
+
+        The CSSRegions spec allows region styling to be applied on the text-shadow property
+        as well. We need to also add this in WebKit.
+
+        Test: fast/regions/region-style-text-shadow.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRulesForList):
+        Make sure we actually collect text-shadow property from parser in an @region rule.
+        * rendering/InlineBox.cpp:
+        (WebCore::InlineBox::styleInRegion):
+        (WebCore):
+        (WebCore::InlineBox::regionDuringLayout):
+        * rendering/InlineBox.h:
+        (WebCore):
+        (InlineBox):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::addToLine):
+        Take into account region styling, so that "knownToHaveNoOverflow" is computed
+        properly.
+        (WebCore::InlineFlowBox::addTextBoxVisualOverflow):
+        Take into account region styling, so that the visual overflow rect is computed
+        properly.
+        * rendering/RenderRegion.h:
+        (RenderRegion):
+        Made computeStyleInRegion public.
+
 2012-08-30  Andreas Kling  <[email protected]>
 
         Element: Share code between setAttributeNode() and other attribute setters.

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (127130 => 127131)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-08-30 13:19:42 UTC (rev 127131)
@@ -3277,6 +3277,7 @@
     switch (id) {
     case CSSPropertyBackgroundColor:
     case CSSPropertyColor:
+    case CSSPropertyTextShadow:
         return true;
     default:
         break;

Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (127130 => 127131)


--- trunk/Source/WebCore/rendering/InlineBox.cpp	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp	2012-08-30 13:19:42 UTC (rev 127131)
@@ -28,6 +28,9 @@
 #include "PaintInfo.h"
 #include "RenderArena.h"
 #include "RenderBlock.h"
+#include "RenderFlowThread.h"
+#include "RenderRegion.h"
+#include "RenderStyle.h"
 #include "RootInlineBox.h"
 
 #ifndef NDEBUG
@@ -251,6 +254,30 @@
     return renderer()->hitTest(request, result, locationInContainer, accumulatedOffset);
 }
 
+RenderStyle* InlineBox::styleInRegion(RenderRegion* region)
+{
+    if (!region || !renderer()->inRenderFlowThread())
+        return renderer()->style(isFirstLineStyle());
+    RenderObject* elementRenderer = renderer();
+    while (elementRenderer && (elementRenderer->isAnonymous() || !elementRenderer->node() || !elementRenderer->node()->isElementNode()))
+        elementRenderer = elementRenderer->parent();
+    if (!elementRenderer)
+        return renderer()->style(isFirstLineStyle());
+    // FIXME: We should be taking into account isFirstLine
+    return region->computeStyleInRegion(elementRenderer).get();
+}
+
+RenderRegion* InlineBox::regionDuringLayout()
+{
+    // This assumes that the box has not been positioned yet, so it uses the containing block's current logical height to get the region.
+    if (!renderer()->inRenderFlowThread())
+        return 0;
+    RenderFlowThread* flowThread = renderer()->enclosingRenderFlowThread();
+    ASSERT(flowThread);
+    RenderBlock* containingBlock = renderer()->containingBlock();
+    return flowThread->regionAtBlockOffset(containingBlock->offsetFromLogicalTopOfFirstPage() + containingBlock->logicalHeight());
+}
+
 const RootInlineBox* InlineBox::root() const
 { 
     if (m_parent)

Modified: trunk/Source/WebCore/rendering/InlineBox.h (127130 => 127131)


--- trunk/Source/WebCore/rendering/InlineBox.h	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2012-08-30 13:19:42 UTC (rev 127131)
@@ -28,6 +28,8 @@
 
 class HitTestRequest;
 class HitTestResult;
+class RenderStyle;
+class RenderRegion;
 class RootInlineBox;
 
 // InlineBox represents a rectangle that occurs on a line.  It corresponds to
@@ -97,6 +99,8 @@
     virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom);
 
+    RenderStyle* styleInRegion(RenderRegion*);
+    RenderRegion* regionDuringLayout();
     // Overloaded new operator.
     void* operator new(size_t, RenderArena*);
 

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (127130 => 127131)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2012-08-30 13:19:42 UTC (rev 127131)
@@ -159,7 +159,7 @@
 
     if (!child->renderer()->isOutOfFlowPositioned()) {
         if (child->isText()) {
-            RenderStyle* childStyle = child->renderer()->style(isFirstLineStyle());
+            RenderStyle* childStyle = child->styleInRegion(child->regionDuringLayout());
             if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth())
                 child->clearKnownToHaveNoOverflow();
         } else if (child->renderer()->isReplaced()) {
@@ -820,8 +820,7 @@
     if (textBox->knownToHaveNoOverflow())
         return;
 
-    RenderStyle* style = textBox->renderer()->style(isFirstLineStyle());
-    
+    RenderStyle* style = textBox->styleInRegion(textBox->regionDuringLayout());
     GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox);
     GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->second.second;
     bool isFlippedLine = style->isFlippedLinesWritingMode();

Modified: trunk/Source/WebCore/rendering/RenderRegion.h (127130 => 127131)


--- trunk/Source/WebCore/rendering/RenderRegion.h	2012-08-30 13:04:50 UTC (rev 127130)
+++ trunk/Source/WebCore/rendering/RenderRegion.h	2012-08-30 13:19:42 UTC (rev 127131)
@@ -107,6 +107,7 @@
     virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const;
 
     virtual void expandToEncompassFlowThreadContentsIfNeeded() {};
+    PassRefPtr<RenderStyle> computeStyleInRegion(const RenderObject*);
 
 protected:
     void setRegionObjectsRegionStyle();
@@ -122,7 +123,6 @@
 
     virtual void installFlowThread();
 
-    PassRefPtr<RenderStyle> computeStyleInRegion(const RenderObject*);
     void computeChildrenStyleInRegion(const RenderObject*);
     void setObjectStyleInRegion(RenderObject*, PassRefPtr<RenderStyle>, bool objectRegionStyleCached);
     void printRegionObjectsStyles();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to