Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WebHistoryController: Refactor menu search to be recursive

This way it doesn't matter where in an element you click, as
long as one of its parents has the required attributes, you
get the menu
  • Loading branch information...
commit c9609f22b69260928b5f7979f6944116a5b8b424 1 parent 47e182a
@pieter authored
Showing with 13 additions and 13 deletions.
  1. +13 −13 PBWebHistoryController.m
View
26 PBWebHistoryController.m
@@ -76,21 +76,21 @@ - (NSArray *) webView:(WebView *)sender
{
DOMNode *node = [element valueForKey:@"WebElementDOMNode"];
- // If clicked on the text, select the containing div
- if ([[node className] isEqualToString:@"DOMText"])
- node = [node parentNode];
-
- // Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref.
- if (![[node className] hasPrefix:@"refs "])
- return defaultMenuItems;
+ while (node) {
+ // Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref.
+ if ([[node className] hasPrefix:@"refs "]) {
+ NSString *selectedRefString = [[[node childNodes] item:0] textContent];
+ for (PBGitRef *ref in historyController.webCommit.refs)
+ {
+ if ([[ref shortName] isEqualToString:selectedRefString])
+ return [contextMenuDelegate menuItemsForRef:ref commit:historyController.webCommit];
+ }
+ NSLog(@"Could not find selected ref!");
+ return defaultMenuItems;
+ }
- NSString *selectedRefString = [[[node childNodes] item:0] textContent];
- for (PBGitRef *ref in historyController.webCommit.refs)
- {
- if ([[ref shortName] isEqualToString:selectedRefString])
- return [contextMenuDelegate menuItemsForRef:ref commit:historyController.webCommit];
+ node = [node parentNode];
}
- NSLog(@"Could not find selected ref!");
return defaultMenuItems;
}
Please sign in to comment.
Something went wrong with that request. Please try again.