Changeset 214864 in webkit


Ignore:
Timestamp:
Apr 3, 2017 8:30:30 PM (7 years ago)
Author:
BJ Burg
Message:

Web Inspector: RTL: results in Search navigation sidebar have misplaced highlights
https://bugs.webkit.org/show_bug.cgi?id=170292

Reviewed by Timothy Hatcher.

  • UserInterface/Models/SourceCodeSearchMatchObject.js:

(WebInspector.SourceCodeSearchMatchObject.prototype.get className):

  • UserInterface/Views/SearchIcons.css:

(.source-code-match .icon):
(.source-code-match-icon .icon): Deleted.
Remove -icon suffix from the class name since the class is attached to a result
and is not specific to the icon displayed within the result <li>.

  • UserInterface/Views/SearchResultTreeElement.js:

(WebInspector.SearchResultTreeElement.truncateAndHighlightTitle):
Flip the leading and trailing context in RTL so that the highlight is not overflowed
to the left when too much context is included on the right side. Less context must be
used in RTL because we must not overflow to the right, as it may hide the result. And,
we don't know the exact starting character either as it may be overflowed to the right
as the user resizes the expanded sidebar larger or smaller. So show less context to
be conservative about never overflowing the highlighted result string.

  • UserInterface/Views/SearchSidebarPanel.css:

(.sidebar > .panel.navigation.search .item.source-code-match .title):
When in RTL, show source code matches as LTR with text-align to right.

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r214863 r214864  
     12017-04-03  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: RTL: results in Search navigation sidebar have misplaced highlights
     4        https://bugs.webkit.org/show_bug.cgi?id=170292
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Models/SourceCodeSearchMatchObject.js:
     9        (WebInspector.SourceCodeSearchMatchObject.prototype.get className):
     10        * UserInterface/Views/SearchIcons.css:
     11        (.source-code-match .icon):
     12        (.source-code-match-icon .icon): Deleted.
     13        Remove -icon suffix from the class name since the class is attached to a result
     14        and is not specific to the icon displayed within the result <li>.
     15
     16        * UserInterface/Views/SearchResultTreeElement.js:
     17        (WebInspector.SearchResultTreeElement.truncateAndHighlightTitle):
     18        Flip the leading and trailing context in RTL so that the highlight is not overflowed
     19        to the left when too much context is included on the right side. Less context must be
     20        used in RTL because we must not overflow to the right, as it may hide the result. And,
     21        we don't know the exact starting character either as it may be overflowed to the right
     22        as the user resizes the expanded sidebar larger or smaller. So show less context to
     23        be conservative about never overflowing the highlighted result string.
     24
     25        * UserInterface/Views/SearchSidebarPanel.css:
     26        (.sidebar > .panel.navigation.search .item.source-code-match .title):
     27        When in RTL, show source code matches as LTR with text-align to right.
     28
    1292017-04-03  Devin Rousso  <webkit@devinrousso.com>
    230
  • trunk/Source/WebInspectorUI/UserInterface/Models/SourceCodeSearchMatchObject.js

    r204507 r214864  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4747    get className()
    4848    {
    49         return WebInspector.SourceCodeSearchMatchObject.SourceCodeMatchIconStyleClassName;
     49        return "source-code-match";
    5050    }
    5151
     
    6060};
    6161
    62 WebInspector.SourceCodeSearchMatchObject.SourceCodeMatchIconStyleClassName = "source-code-match-icon";
    63 
    6462WebInspector.SourceCodeSearchMatchObject.TypeIdentifier = "source-code-search-match-object";
    6563WebInspector.SourceCodeSearchMatchObject.URLCookieKey = "source-code-url";
  • trunk/Source/WebInspectorUI/UserInterface/Views/SearchIcons.css

    r176358 r214864  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848}
    4949
    50 .source-code-match-icon .icon {
     50.source-code-match .icon {
    5151    content: url(../Images/ResultLine.svg);
    5252}
  • trunk/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js

    r213000 r214864  
    11/*
    2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939    static truncateAndHighlightTitle(title, searchTerm, sourceCodeTextRange)
    4040    {
     41        let isRTL = WebInspector.resolvedLayoutDirection() === WebInspector.LayoutDirection.RTL;
     42        const charactersToShowBeforeSearchMatch = isRTL ? 20 : 15;
     43        const charactersToShowAfterSearchMatch = isRTL ? 15 : 50;
     44
    4145        // Use the original location, since those line/column offsets match the line text in title.
    4246        var textRange = sourceCodeTextRange.textRange;
     
    5054        // at the end of the string.
    5155        var modifiedTitle = null;
    52         if (searchTermIndex > WebInspector.SearchResultTreeElement.CharactersToShowBeforeSearchMatch) {
    53             modifiedTitle = ellipsis + title.substring(searchTermIndex - WebInspector.SearchResultTreeElement.CharactersToShowBeforeSearchMatch);
    54             searchTermIndex = WebInspector.SearchResultTreeElement.CharactersToShowBeforeSearchMatch + 1;
     56        if (searchTermIndex > charactersToShowBeforeSearchMatch) {
     57            modifiedTitle = ellipsis + title.substring(searchTermIndex - charactersToShowBeforeSearchMatch);
     58            searchTermIndex = charactersToShowBeforeSearchMatch + 1;
    5559        } else
    5660            modifiedTitle = title;
    5761
    5862        // Truncate the tail of the title so the tooltip isn't so large.
    59         modifiedTitle = modifiedTitle.trimEnd(searchTermIndex + searchTerm.length + WebInspector.SearchResultTreeElement.CharactersToShowAfterSearchMatch);
     63        modifiedTitle = modifiedTitle.trimEnd(searchTermIndex + searchTerm.length + charactersToShowAfterSearchMatch);
    6064
    6165        console.assert(modifiedTitle.substring(searchTermIndex, searchTermIndex + searchTerm.length).toLowerCase() === searchTerm.toLowerCase());
     
    8791    }
    8892};
    89 
    90 WebInspector.SearchResultTreeElement.CharactersToShowBeforeSearchMatch = 15;
    91 WebInspector.SearchResultTreeElement.CharactersToShowAfterSearchMatch = 50;
  • trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css

    r202064 r214864  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5252    margin-right: 4px;
    5353}
     54
     55body[dir=rtl] .sidebar > .panel.navigation.search .item.source-code-match {
     56    direction: ltr;
     57    text-align: right;
     58}
Note: See TracChangeset for help on using the changeset viewer.