Bug 128194 - Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
Summary: Convert position:sticky and position:fixed properties to position:static and ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-02-04 10:50 PST by Myles C. Maxfield
Modified: 2014-02-12 10:37 PST (History)
7 users (show)

See Also:


Attachments
Patch (6.72 KB, patch)
2014-02-04 15:20 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (25.94 KB, patch)
2014-02-10 19:41 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (23.76 KB, patch)
2014-02-10 19:51 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (24.02 KB, patch)
2014-02-11 12:36 PST, Myles C. Maxfield
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2014-02-04 10:50:09 PST
Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
Comment 1 Myles C. Maxfield 2014-02-04 15:20:26 PST
Created attachment 223168 [details]
Patch
Comment 2 Myles C. Maxfield 2014-02-04 15:32:10 PST
<rdar://problem/15696956>
Comment 3 Simon Fraser (smfr) 2014-02-04 16:08:51 PST
Comment on attachment 223168 [details]
Patch

It's not clear to me that we want to do this unconditionally on copy; you'll break lots of HTML editors. Seems like the recipient of the paste needs to do the mungeing.
Comment 4 Ryosuke Niwa 2014-02-06 16:32:08 PST
Comment on attachment 223168 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223168&action=review

> Source/WebCore/editing/EditingStyle.cpp:1232
> +    if (m_mutableStyle->propertyMatches(CSSPropertyPosition, sticky.get()))
> +        m_mutableStyle->setProperty(CSSPropertyPosition, cssValuePool().createIdentifierValue(CSSValueStatic), false);

We should probably preserve the importance of the property.

> Source/WebCore/editing/markup.cpp:322
> +            
> +            newInlineStyle->convertFixedAndStickyPosition();

We need this function to return a boolean and keep that state in StyledMarkupAccumulator
so that we can remember to wrap the whole thing with position:relative block.

Also, Simon is right in that we don't want to do this unless we're copying the entire document
so we need the constructor of StylizedMarkupAccumulator to take some enum/boolean for that as well.
Comment 5 Simon Fraser (smfr) 2014-02-06 16:44:00 PST
> Also, Simon is right in that we don't want to do this unless we're copying the entire document
Why? I still think this should be a paste-time filter.
Comment 6 Ryosuke Niwa 2014-02-06 16:48:04 PST
(In reply to comment #5)
> > Also, Simon is right in that we don't want to do this unless we're copying the entire document
> Why? I still think this should be a paste-time filter.

No, at the paste time, we don't know where elements are placed.  Also, copy-time is where we do all these style serializations.

We used to have some code in paste side trying to fix the content and that was an epic fail. We've moved most of that stuff into copy site over time.
Comment 7 Myles C. Maxfield 2014-02-07 16:12:20 PST
Comment on attachment 223168 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223168&action=review

>> Source/WebCore/editing/EditingStyle.cpp:1232
>> +        m_mutableStyle->setProperty(CSSPropertyPosition, cssValuePool().createIdentifierValue(CSSValueStatic), false);
> 
> We should probably preserve the importance of the property.

Done.

>> Source/WebCore/editing/markup.cpp:322
>> +            newInlineStyle->convertFixedAndStickyPosition();
> 
> We need this function to return a boolean and keep that state in StyledMarkupAccumulator
> so that we can remember to wrap the whole thing with position:relative block.
> 
> Also, Simon is right in that we don't want to do this unless we're copying the entire document
> so we need the constructor of StylizedMarkupAccumulator to take some enum/boolean for that as well.

Done. I'm doing that check in createMarkupInternal
Comment 8 Myles C. Maxfield 2014-02-10 19:41:01 PST
Created attachment 223795 [details]
Patch
Comment 9 Myles C. Maxfield 2014-02-10 19:51:12 PST
Created attachment 223797 [details]
Patch
Comment 10 Simon Fraser (smfr) 2014-02-10 21:58:22 PST
Comment on attachment 223795 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223795&action=review

> Source/WebCore/ChangeLog:13
> +        block (position:relative) is wrapped around the copied text. If there is a position:-webkit-sticky
> +        element, it is replaced with position:static.

You should convert sticky to position:relative, so that positioned descendants stay more or less in the same place.
Comment 11 Myles C. Maxfield 2014-02-11 11:25:58 PST
Comment on attachment 223795 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223795&action=review

>> Source/WebCore/ChangeLog:13
>> +        element, it is replaced with position:static.
> 
> You should convert sticky to position:relative, so that positioned descendants stay more or less in the same place.

Done.
Comment 12 Myles C. Maxfield 2014-02-11 12:36:25 PST
Created attachment 223889 [details]
Patch
Comment 13 Myles C. Maxfield 2014-02-11 12:37:12 PST
Related: https://bugs.webkit.org/show_bug.cgi?id=128616
Comment 14 Myles C. Maxfield 2014-02-11 16:02:37 PST
http://trac.webkit.org/changeset/163916
Comment 15 Ryosuke Niwa 2014-02-11 18:13:21 PST
Comment on attachment 223889 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223889&action=review

> Source/WebCore/editing/markup.cpp:330
> +            if (element.document().settings() && element.document().settings()->convertPositionStyleOnCopy())
> +                m_needRelativeStyleWrapper |= newInlineStyle->convertFixedAndStickyPosition();

There's a bug here. This is isn't checking thatfullySelectedRoot == body was true in createMarkupInternal :(
As such, this code runs even if the entire body wasn't selected.
Comment 16 Myles C. Maxfield 2014-02-12 10:37:35 PST
Comment on attachment 223889 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223889&action=review

>> Source/WebCore/editing/markup.cpp:330
>> +                m_needRelativeStyleWrapper |= newInlineStyle->convertFixedAndStickyPosition();
> 
> There's a bug here. This is isn't checking thatfullySelectedRoot == body was true in createMarkupInternal :(
> As such, this code runs even if the entire body wasn't selected.

Oh man. This was fixed in an earlier version of the patch, but must have gotten lost in refactoring. :-(