Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This method checks if |start| and
- // |dest| have a partial intersection, either
- // horizontally or vertically.
- // * a = Current focused node's rect.
- // * b = Focus candidate node's rect.
- static bool areRectsPartiallyAligned(....)
- {
- int aStart = start(direction, a);
- int bStart = start(direction, b);
- int bMiddle = middle(direction, b);
- int aEnd = end(direction, a);
- int bEnd = end(direction, b);
- // Picture of the partially aligned logic:
- //
- // Horizontal Vertical
- // ********************************
- // * _ * _ _ _ *
- // * |_| * |_|_|_| *
- // * |_|.... _ * . . *
- // * |_| |_| * . . *
- // * |_|....|_| * ._._ _ *
- // * |_| * |_|_|_| *
- // * |_| * *
- // * * *
- // ********************************
- //
- // ... and variants of the above cases.
- return ((bStart >= aStart && bStart <= aEnd)
- || (bStart >= aStart && bStart <= aEnd)
- || (bEnd >= aStart && bEnd <= aEnd)
- || (bMiddle >= aStart && bMiddle <= aEnd)
- || (bEnd >= aStart && bEnd <= aEnd));
- }
- The (bStart >= aStart && bStart <= aEnd) comparison is repeated twice. I cannot say for sure what should be written instead of this.
- This suspicious code was found in WebKit project by PVS-Studio static code analyzer.
- Warning message is:
- V501 There are identical sub-expressions '(bStart >= aStart && bStart <= aEnd)' to the left and to the right of the '||' operator. webcore_remaining spatialnavigation.cpp 236
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment