Bug 174470 - Incorrect call to StyledElement::setInlineStyleProperty in ImageDocument::createDocumentStructure
Summary: Incorrect call to StyledElement::setInlineStyleProperty in ImageDocument::cre...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Other
Hardware: PC All
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on:
Blocks: 174463
  Show dependency treegraph
 
Reported: 2017-07-13 11:33 PDT by Michael Catanzaro
Modified: 2017-07-13 18:53 PDT (History)
8 users (show)

See Also:


Attachments
Patch (1.51 KB, patch)
2017-07-13 11:34 PDT, Michael Catanzaro
darin: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews126 for ios-simulator-wk2 (935.50 KB, application/zip)
2017-07-13 15:49 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2017-07-13 11:33:34 PDT
Here is another good GCC 7 warning:

[3172/5861] Building CXX object Source...s/WebCore.dir/html/ImageDocument.cpp.o
../../Source/WebCore/html/ImageDocument.cpp: In member function ‘void WebCore::ImageDocument::createDocumentStructure()’:
../../Source/WebCore/html/ImageDocument.cpp:226:103: warning: enum constant in boolean context [-Wint-in-bool-context]
         body->setInlineStyleProperty(CSSPropertyBackgroundColor, "white", CSSPrimitiveValue::CSS_IDENT);

This call to StyledElement::setInlineStyleProperty inside ImageDocument::createDocumentStructure is incorrect:

    if (MIMETypeRegistry::isPDFMIMEType(document().loader()->responseMIMEType()))
        body->setInlineStyleProperty(CSSPropertyBackgroundColor, "white", CSSPrimitiveValue::CSS_IDENT);

Here are the overloads:

    bool setInlineStyleProperty(CSSPropertyID, CSSValueID identifier, bool important = false);
    bool setInlineStyleProperty(CSSPropertyID, CSSPropertyID identifier, bool important = false);
    WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, double value, CSSPrimitiveValue::UnitType, bool important = false);
    WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, const String& value, bool important = false);

Currently it is calling the final overload (CSSPropertyID, const String& value, bool important = false). Surely it is not intended for CSSPrimitiveValue::CSS_IDENT to be implicitly converted to bool (important = true), as is currently occurring. I think the proper fix is probably to just remove that argument. However, I am not sure, because I'm not sure how the important flag is supposed to be used. This is a behavior change, so it would be good for someone familiar with how the code is intended to work to review it.
Comment 1 Michael Catanzaro 2017-07-13 11:34:33 PDT
Created attachment 315362 [details]
Patch
Comment 2 Michael Catanzaro 2017-07-13 13:45:46 PDT
(The way to do this with no behavior change would be to replace CSSPrimitiveValue::CSS_IDENT with true. But I suspect that's not right.)
Comment 3 Darin Adler 2017-07-13 13:48:54 PDT
Comment on attachment 315362 [details]
Patch

There was no great harm in the background color property being set as important, but it was definitely not intentional either.
Comment 4 Build Bot 2017-07-13 15:49:19 PDT
Comment on attachment 315362 [details]
Patch

Attachment 315362 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/4115353

New failing tests:
imported/w3c/web-platform-tests/IndexedDB/large-nested-cloning.html
Comment 5 Build Bot 2017-07-13 15:49:20 PDT
Created attachment 315380 [details]
Archive of layout-test-results from ews126 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.5
Comment 6 Michael Catanzaro 2017-07-13 18:38:14 PDT
(In reply to Darin Adler from comment #3)
> There was no great harm in the background color property being set as
> important, but it was definitely not intentional either.

Is there any documentation for what property importance means? I'm curious.
Comment 7 Michael Catanzaro 2017-07-13 18:38:59 PDT
Committed r219479: <http://trac.webkit.org/changeset/219479>
Comment 8 Tim Horton 2017-07-13 18:41:14 PDT
(In reply to Michael Catanzaro from comment #6)
> (In reply to Darin Adler from comment #3)
> > There was no great harm in the background color property being set as
> > important, but it was definitely not intentional either.
> 
> Is there any documentation for what property importance means? I'm curious.

Pretty sure it's the "!important" bit in CSS, which is ... well documented elsewhere (see MDN maybe?).
Comment 9 Michael Catanzaro 2017-07-13 18:53:24 PDT
OK, thanks!