Bug 51219 - queryCommandValue("FormatBlock") does not respect editing boundaries
Summary: queryCommandValue("FormatBlock") does not respect editing boundaries
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Enhancement
Assignee: Ryosuke Niwa
Depends on:
Reported: 2010-12-16 16:15 PST by Ryosuke Niwa
Modified: 2010-12-23 18:34 PST (History)
7 users (show)

See Also:

fixes the bug (4.97 KB, patch)
2010-12-16 16:56 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2010-12-16 16:15:51 PST
document.queryCommandValue("FormatBlock") does not respect the editing boundary.  It returns the name of block even if the block was an ancestor of the editable root or the editable root itself.  Firefox doesn't this do.
Comment 1 Ryosuke Niwa 2010-12-16 16:56:28 PST
Created attachment 76828 [details]
fixes the bug
Comment 2 Ryosuke Niwa 2010-12-16 16:58:55 PST
Comment on attachment 76828 [details]
fixes the bug

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

> WebCore/editing/FormatBlockCommand.cpp:111
>      if (!commonAncestor)
>          return 0;
> +    Element* rootEditableElement = range->startContainer()->rootEditableElement();
> +    if (!rootEditableElement || commonAncestor->contains(rootEditableElement))
> +        return 0;
> +

I could combine these two if statements in practice but I was concerned that there could be a case where startContainer() is null.  While we DO check this condition in valueFormatBlock, I didn't want to make the precondition of this function tighter.
Comment 3 WebKit Commit Bot 2010-12-23 18:33:55 PST
Comment on attachment 76828 [details]
fixes the bug

Clearing flags on attachment: 76828

Committed r74603: <http://trac.webkit.org/changeset/74603>
Comment 4 WebKit Commit Bot 2010-12-23 18:34:01 PST
All reviewed patches have been landed.  Closing bug.