Source/WebCore/ChangeLog

 12011-05-31 Mustafizur Rahaman <mustaf.here@gmail.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 HTML5 Conformance Test failure: approved/canvas/canvas_text_font_001.htm
 6 https://bugs.webkit.org/show_bug.cgi?id=48578
 7
 8 When parsing font attribute for HTML canvas, appropriate behavior for "inherit" was not implemented.
 9 I added a bool to differentiate whether a CSS parser is invoked for parsing normal HTML OR for parsing HTML canvas
 10
 11 Test: fast/canvas/canvas-text-inherit.html
 12
 13 * css/CSSParser.cpp:
 14 (WebCore::CSSParser::CSSParser):
 15 (WebCore::CSSParser::parseFont):
 16 * css/CSSParser.h:
 17 * html/canvas/CanvasRenderingContext2D.cpp:
 18 (WebCore::CanvasRenderingContext2D::setFont):
 19
1202011-05-30 Hayato Ito <hayato@chromium.org>
221
322 Reviewed by Ryosuke Niwa.
87717

Source/WebCore/css/CSSParser.cpp

@@static bool hasPrefix(const char* string
131131 return false;
132132}
133133
134 CSSParser::CSSParser(bool strictParsing)
 134CSSParser::CSSParser(bool strictParsing, bool htmlCanvasParsing)
135135 : m_strict(strictParsing)
 136 , m_parseHTMLCanvas(htmlCanvasParsing)
136137 , m_important(false)
137138 , m_id(0)
138139 , m_styleSheet(0)

@@bool CSSParser::parseFont(bool important
36513652 break;
36523653 value = m_valueList->next();
36533654 }
3654  if (!value)
 3655 if (!value || (this->m_parseHTMLCanvas && value->id == CSSValueInherit))
36553656 return false;
36563657
36573658 // set undefined values to default

@@bool CSSParser::parseFont(bool important
36693670 else if (validUnit(value, FLength | FPercent | FNonNeg, m_strict))
36703671 font->size = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
36713672 value = m_valueList->next();
3672  if (!font->size || !value)
 3673 if (!font->size || (this->m_parseHTMLCanvas && value->id == CSSValueInherit))
36733674 return false;
36743675
36753676 if (value->unit == CSSParserValue::Operator && value->iValue == '/') {
36763677 // line-height
36773678 value = m_valueList->next();
3678  if (!value)
 3679 if (!value || (this->m_parseHTMLCanvas && value->id == CSSValueInherit))
36793680 return false;
36803681 if (value->id == CSSValueNormal) {
36813682 // default value, nothing to do

@@bool CSSParser::parseFont(bool important
36843685 else
36853686 return false;
36863687 value = m_valueList->next();
3687  if (!value)
 3688 if (!value || (this->m_parseHTMLCanvas && value->id == CSSValueInherit))
36883689 return false;
36893690 }
36903691
86221

Source/WebCore/css/CSSParser.h

@@namespace WebCore {
5555
5656 class CSSParser {
5757 public:
58  CSSParser(bool strictParsing = true);
 58 CSSParser(bool strictParsing = true, bool htmlCanvasParsing = false);
5959 ~CSSParser();
6060
6161 void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);

@@namespace WebCore {
229229 void clearProperties();
230230
231231 bool m_strict;
 232 bool m_parseHTMLCanvas;
232233 bool m_important;
233234 int m_id;
234235 CSSStyleSheet* m_styleSheet;
86221

Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

@@String CanvasRenderingContext2D::font()
17531753void CanvasRenderingContext2D::setFont(const String& newFont)
17541754{
17551755 RefPtr<CSSMutableStyleDeclaration> tempDecl = CSSMutableStyleDeclaration::create();
1756  CSSParser parser(!m_usesCSSCompatibilityParseMode);
 1756 CSSParser parser(!m_usesCSSCompatibilityParseMode, true);
17571757
17581758 String declarationText("font: ");
17591759 declarationText += newFont;
86221

LayoutTests/ChangeLog

 12011-05-31 Mustafizur Rahaman <mustaf.here@gmail.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 https://bugs.webkit.org/show_bug.cgi?id=48578
 6
 7 * fast/canvas/canvas-text-inherit-expected.txt: Added.
 8 * fast/canvas/canvas-text-inherit.html: Added.
 9
1102011-05-31 Zoltan Horvath <zoltan@webkit.org>
211
312 [Qt][WK2] Ossyize editing/pasteboard/copy-standalone-image-crash.html since eventSender is not implemented.
87717

LayoutTests/fast/canvas/canvas-text-inherit-expected.txt

 1Tests for border attribute with Object tag
 2Bug 48578 : HTML5 Conformance Test failure: approved/canvas/canvas_text_font_001.htm
 3
 4Test passes if both strings are identical in both size, style, and text.
 5
 6TEST COMPLETE
 7
0

LayoutTests/fast/canvas/canvas-text-inherit.html

 1<!doctype HTML>
 2<html>
 3 <head>
 4 <title>HTML5 Canvas Test: Ignore property-independent style sheet syntax "inherit" in Text</title>
 5 <link rel="author" title="Microsoft" href="http://www.microsoft.com" />
 6 <link rel="help" href="http://www.w3.org/TR/2dcontext/#dom-context-2d-font" />
 7 <meta name="assert" content=": Ignore 'inherit' property-independent style sheet syntax without assigning a new font value." />
 8 <script type="text/javascript">
 9 function runTest()
 10 {
 11 var canvas = document.getElementById("canvas1");
 12 var ctx = canvas.getContext("2d");
 13
 14 // Assign a valid font.
 15 ctx.font = "40px Times New Roman";
 16
 17 // Assign property-independent style sheet syntax 'inherit' as font.
 18 ctx.font = "20px inherit";
 19 ctx.fillText("Test String", 5, 50);
 20
 21 // Assign a valid font which was used earlier.
 22 ctx.font = "40px Times New Roman";
 23 ctx.fillText("Test String", 5, 100);
 24 }
 25 </script>
 26 </head>
 27
 28 <body onload="runTest()">
 29 <p>Description: Ignore "inherit" property-independent style sheet syntax without assigning a new font value.</p>
 30 <p>Test passes if both strings are identical in both size, style, and text.</p>
 31 <canvas id="canvas1" width="300" height="150">Browser does not support HTML5 Canvas.</canvas>
 32 </body>
 33</html>
0