Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is an evil one. A suitably evil pair of actions (neither of them particularly clean or ideal) would be:</p> <ol> <li><p>Do some inline assembler to look back up the stack to read the sender argument from the caller's stack (or the caller's caller, as the case should be). This of course assumes that the sender is placed on the stack and not in <code>%eax</code> when the call to <code>WebHTMLView</code> was made. That will always apply to PowerPC code however, so it's likely a non-starter there.</p></li> <li><p>Put a category on <code>WebHTMLView</code> with a method named something like <code>__my_evil_hacky_nasty_ugly_changeAttributes_thing:</code> and at runtime use method_exchangeImplementations() from the ObjC runtime to swap your category's implementation with theirs. Your method becomes <code>changeAttributes:</code> and theirs becomes <code>__my_evil_hacky_nasty_ugly_changeAttributes_thing:</code>, which you can then call to pass on the original call.</p></li> </ol> <p>As I said, neither is particularly ideal, but the second has the advantage of full runtime support (i.e. the runtime is explicitly designed to let you do this), and since you're looking up the class and methods at runtime, it's failure-tolerant. Failure in this case gets you back to square one however.</p> <p>Really it needs a bug logged against WebKit to have them pass on the sender to make it meaningful at all. Your overridden version could potentially look for a method <code>-(BOOL)webView:(WebView*)webView doCommandBySelector:(SEL)selector sender:(id)sender</code> and call that if found, otherwise just call through to the original method. This is what Apple's code should be doing, TBH.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload